Excel VBA Macros - Hide/UnHide Cells
I am tyring to create macro that will hide cells depending on what data is in the cell. I am currently using this and it is working but I want to be able to use 2 or more as I have different cells that I want hidden depending on what is entered into other
cells.
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("F5") = "Don't Show" Then
Rows("8:9").EntireRow.Hidden = True
Else
Rows("8:9").EntireRow.Hidden = False
End If
End Sub
But I also want this as well. How can I add them together?
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("F9") = "Don't Show" Then
Rows("8:9").EntireRow.Hidden = True
Else
Rows("8:9").EntireRow.Hidden = False
End If
End Sub
Thanks
Hi ALS91,
Since this is a forum for Office client technical issue, not for technical issue in developing. I suggest you posting this issue in Excel for Developer.
http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=exceldev
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you
for your understanding.
Best regards,
Greta Ge
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs.
Similar Messages
-
Powershell Variable from Excel.VBA Macro
Hi Guys!
I don't know if what i'm asking you is achievable.
I've learned how to pass variables/arguments from powershell to Excel/VBA Macro but i need to do the opposite thing.
This is an example of what i want:
Powershell
Excel/VBA Macro
$Input=1 ----------------------------------------------------------------> Sub Macro(input)
$excel.Run("Macro",$Input)
Output=input +6
$output (Expected 7) <---------------------------------------------------- return Output
I don't know how to do this can you help me please?
AOk guys those are the script.
Macro:
Sub CreatePWD()
Dim PWD As String
Dim i As Integer
Dim Max As Integer
Dim F1 As Worksheet
Set F1 = ThisWorkbook.Worksheets("Foglio1")
Max = F1.Range("A1").Value
For i = 1 To Max
If Int((2 * Rnd) + 1) = 1 Then
PWD = PWD & Chr(Int((90 - 65 + 1) * Rnd + 65))
Else
PWD = PWD & Int((9 - 0 + 1) * Rnd + 0)
End If
Next i
MsgBox PWD
End Sub
Powershell:
$Excel = New-Object -ComObject excel.application
$Excel.visible=$false
$Version = "C:\Users\Alberto Corona\Desktop\Cartel1.xlsm"
$WorkBook= $Excel.workbooks.open($Version)
$WorkSheet= $WorkBook.worksheets.item(1)
$WorkSheet.cells.item(1,1)=5
$Excel.Run("CreatePWD")
$WorkBook.save()
$WorkBook.close()
$Excel.quit()
The result of macro is like "52UT7" i want a variable in powershell called $PWD that contain the value of the macro.
Hope the problem is clear now.
Thanks
A -
Copying Graphs and Pie Charts generated in Analysis View to Email item using Excel VBA Macro Code
Hi
I am currently working on an exce VBA macro code that would help me take snapshots of the Graphs and Pie charts generated in QC for a particular application and copy the same to an email item using excel VBA macro code.
I was able to write the code to create an email item. But I have no clue of how i can take snapshot of the graphs in Analysis View using excel VBA
Any help would be highly appreciated.
Thanks in Advance
Regards
Amituseramit,
You are in the consumer end products forum. You will also want to ask your question over at the Enterprise Business Community.
Click the plus sign (+) next to Discussion Boards to drop down all the options for servers, networking and any other professionally related problems.
http://h30499.www3.hp.com/ -
Call Transaction from Excel VBA macro and download ALV list object results
I have a situation that must be very common u2013 but I canu2019t find any clear information on how to get it done!
We frequently run SAP transactions, download the results (orders or inventory) into Excel, do some calculations and create a spreadsheet report.
I would like to automate this process using Excel VBA so that a macro will perform these steps:
1. Run our custom SAP report "YSD033" that summarizes orders using the previous day as the [From Date] parameter. (The user already has an active ECC 6 R3 session running.) If possible, can the TC be run using a specific variant "G111BIZ" ?
2. Download the list object that appears in an ALV grid as a table to an empty spreadsheet in the active workbook (export XXL list object)
3. Save the resulting workbook and close Excel.
Should the solution use u201Ccall transactionu201D or a GuiXT script?
Any help would be much appreciated, and some sample VBA code would be great!
Thanks.
GlennGood suggestion, but
I get "permission denied" for SapGuiAuto.GetScriptingEngine
I also tried the method below, but received this RFC error message:
User PPPPPPP has no RFC authorization for function group SYST.
Sub LoginCheck()
If login = False Then
' Setting the necessary variables for R/3 connection
Set objBAPICortrol = CreateObject("SAP.Functions")
Set objConnection = objBAPICortrol.Connection
' Establish a connection
If objConnection.Logon(0, False) Then
login = True
MsgBox "Connection Established"
CommandButton1.Caption = "Disconnect"
End If
Else
CommandButton1.Caption = "Connect 2 SAP"
login = False
objConnection.Logoff
Set objConnection = Nothing
Set objBAPICortrol = Nothing
End If
End Sub
I was told that these kinds of authority open up too big of a window that can't be monitored adequately...
I'm considering an approach like what is below if I can't convince security to grant me permissions...
Application.Wait Now + TimeValue("00:00:01")
SendKeys EnterKey, False
Since blocked RFC security settings are preventing the solution from being installed, I am markgin this question as answered.
I will post different questions about 1. how to convince the security team that it will be safe to allow the use of RFC calls, and /or 2. how use some windows-level scripting code to run the SAP jobs.
Thanks.
Edited by: GlennWebster on Mar 1, 2010 4:34 PM -
Using AppleScript to Launch Excel VBA Macro
Using MS Office 2004 and AppleScript 1.9.3. I want to use AppleScript in MS Entourage to kick off a VBA macro in Excel. But no luck.
To test things, I created an Excel file ("test.xls") with a one-line VBA macro named "test." It just puts up a dialog box with the message "success." I'm calling it from A.S as follows (per the AppleScript Dictionary for Excel 2004):
tell application "Microsoft Excel"
run VB macro "hard disk:users:xxx:desktop:test.xls!test"
end tell
I get two successive error messages:
1. 'test.xls' cannot be accessed. The file may be read-only or you may be trying to access a read-only location."
2. "Microsoft Excel got an error: "hard disk:users:xxx:desktop:test.xls!test" doesn't understand the run VB macro message."
"test" file permissions are -rw-r--r-- and it is sitting right on the desktop.
FWIW, I did not remove the old Office vX yet, but renamed old Excel "Microsoft ExcelOld". I read on some other site that this may cause problems.
This has been endlessly frustrating. HELP!!??
SteveHi Steve,
Have you tried dealing with the return value from your macro? If you are invoking the MsgBox function in your test macro, you may need to allow the return value from MsgBox to pass thru back to AS. Something like :
set MyRetCode to run VB macro "Macintosh HD:Users:xxx:Desktop:test.xls!test"
(Note unless you've changed the hard drive name to "hard drive", the default boot drive name will probably be "Macintosh HD". Case does matter here)
I also suspect you'll need to have Entourage up as well in the full case of running a macro in Entourage from Excel (or the other way around). Hence, the command ActivateMicrosoftApp in the Excel dictionary may also be useful.
Second, you can have a macro, in a startup template, in Entourage call a macro in a startup template in Excel to accomplish what you want without going into AppleScript at all. This latter, VB-only, method will require a "Reference", as it's called in VBA, to be added to the TemplateProject in Entourage that points to the Excel macro you want to fire off. The added benefit of this latter method is that you will have access to the full range of VBA commands/options, rather than the smaller dictionary available in AS.
Ed
PB G4 Mac OS X (10.2.x) -
Excel-VBA Macro Connectivity to XE
I have an excel-macro which accesses data from Oracle9i database with the connection code;
Set oOraSession = CreateObject("OracleInProcServer.XOraSession")
Set oOraDatabase = oOraSession.OpenDatabase("iois", "bacc/password", 0&)
It runs smoothly with no problems. When I test the same application to my newly installed XE database, using the connection code;
Set oOraSession = CreateObject("OracleInProcServer.XOraSession")
Set oOraDatabase = oOraSession.OpenDatabase("XE.world", "bacc/password", 0&)
it didnt run and broadcasts an error msg.;
Runtime error '429'
ActiveX component can't create object
I know there's a way to solve this but how?
ArnelHi Arnel,
you might try the easy connect syntax, works fine for me.
Sub GetEmployees()
' Use OO4O
Set objSession = CreateObject("OracleInProcServer.XOraSession")
Set objDatabase = objSession.OpenDatabase("127.0.0.1:1521/XE", "hr/oracle1", 0)
Sql = "select * from emp"
Set oraDynaSet = objDatabase.DBCreateDynaset(Sql, 0)
If oraDynaSet.RecordCount > 0 Then
oraDynaSet.MoveFirst
For x = 0 To oraDynaSet.Fields.Count - 1
Cells(1, x + 1) = oraDynaSet.Fields(x).Name
'Cells(1, x + 1).Format = Bold
Next
For y = 0 To oraDynaSet.RecordCount - 1
For x = 0 To oraDynaSet.Fields.Count - 1
Cells(y + 2, x + 1) = oraDynaSet.Fields(x).Value
Next
oraDynaSet.MoveNext
Next
End If
Set objSession = Nothing
Set objDatabase = Nothing
End SubRegards,
~Dietmar. -
Problem with controlling Annotations from Excel VBA
Hi,
I have a PDF document that has plenty of sticky notes attached to it. These sticky notes have been added by multiple authors on all pages of the document. I am trying to import the contents of these sticky notes, their author and the page number to an excel spreadsheet. I am using Excel 2007 and Acrobat Professional 9.0.
This is the code that I am currently using to import the sticky notes, but the problem that I am facing is that when I run the macro -
Same sticky note contents, author and page numbers are imported multiple times
Not all sticky notes are imported, only some of them appear in the final excel spreadsheet
When I compare the number of sticky notes to that in the original PDF file, the number is correct. But the content is repeated content and that is the reason why only some of the sticky notes are imported.
This is an activity that I need to do on regular basis and the number of sticky notes that I need to import to excel may range between 100 to 200. It is really difficult to do this task manually, so an excel VBA macro could prove really helpful.
Sub ImportComments_Click()
Dim Fpath As String
Dim WordObj As Object
Dim wbkOutput As Excel.Workbook
Dim iRow As Integer
Dim i, j, k As Integer
Dim lRet As Long
Dim objAcroAVDoc As New Acrobat.acroAVDoc
Dim objAcroPDDoc As Acrobat.AcroPDDoc
Dim numPages As Long
Dim lAnnotscnt As Long
Dim Subtype As String
Dim NumComments As Long
Dim AcroApp As Acrobat.AcroApp
Dim objAcroPDPage As Acrobat.AcroPDPage
Dim annot As Acrobat.AcroPDAnnot
Sheets("Defect Log").Select
Range("L3").Activate
Fpath = ActiveCell.Value
Sheets("Defect Log").Select
Range("A1").Activate
i = 0
Do While (Not (IsEmpty(ActiveCell.Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 1).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 2).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 3).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 4).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 5).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 6).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 7).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 8).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 9).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 10).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 11).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 12).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 13).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 14).Value)))
i = i + 1
ActiveCell.Offset(1, 0).Select
Loop
iRow = i + 1
Set wbkOutput = ActiveWorkbook
lRet = objAcroAVDoc.Open(Fpath, "")
Set objAcroPDDoc = objAcroAVDoc.GetPDDoc
numPages = objAcroPDDoc.GetNumPages()
Set objAcroPDPage = objAcroPDDoc.AcquirePage(0)
For k = 1 To numPages
lAnnotscnt = objAcroPDPage.GetNumAnnots()
For m = 0 To lAnnotscnt - 1
If lAnnotscnt = 0 Then Exit For
Set objAcroPDAnnot = objAcroPDPage.GetAnnot(m)
If (objAcroPDAnnot.GetContents <> "" And objAcroPDAnnot.GetSubtype = "Text") Then
Cells(iRow, 5).Value = k
Cells(iRow, 2).Value = objAcroPDAnnot.GetContents()
Cells(iRow, 11).Value = objAcroPDAnnot.GetTitle()
iRow = iRow + 1
End If
Next m
Set objAcroPDPage = objAcroPDDoc.AcquirePage(k)
Next k
lRet = objAcroAVDoc.Close(1)
Set objAcroAVDoc = Nothing
Set objAcroPDAnnot = Nothing
Set objAcroPDPage = Nothing
Set objAcroPDDoc = Nothing
End SubMake sure you are current with 9.x patches, just on general principles.
The code seems fine – nothing jumping out at me.
You can also look at using the JSObject methods and trying this via the JavaScript stuff – that will give you more access to the Annotation information…
From: Adobe Forums <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Date: Thu, 24 Nov 2011 04:25:12 -0800
To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
Subject: Problem with controlling Annotations from Excel VBA
Problem with controlling Annotations from Excel VBA
created by apreeti<http://forums.adobe.com/people/apreeti> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4044740#4044740 -
Fill a PDF form via Excel (VBA) - Hide text box
Hi,
i already created a PDF form and also can fill the text boxes with Excel VBA.
Now i'm about to hide some fields if they are empty, but i have no clue how to.
My code to fill the fields is:
Fields("Title").Value = Worksheets(TabName).Cells(actCell, 4).Value
To hide a field the code should be similar, but i have no clue what statement i need to set.
I already tried:
Fields("Title").Visible = False
Fields("Title").Hide
Fields("Title").Hide = True
What else can i type to hide and unhide the fields?
Looking forward to hear from you.
Thanks a lot.Does the form have a provision to insert images (e.g. a Browse button)?
[topic moved to iOS subforum] -
How to delete formula from cells and keep the values in Excel VBA
Hi,
In my Excel I have 15 columns. In column F which has a formula (INDEX MATCH), it has contains "RECEIVED" and "INTRANSIT". I need to filter the column F for all "RECEIVED" and then remove the formula from cells and
retain or keep the values that are already in the cells. something tricky and i'm not sure on how to work on this in Excel VBA.
Below is my initla VBA code:
I already have the codes on how to filter. kindly please help me on how to do this. thank you in advance.
Sub test_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim lrow As Long
Set wb = ThisWorkbook
Set ws = wb.Sheets("Intransit_")
Application.ScreenUpdating = False
ws.AutoFilterMode = False
With ws
lrow = .Range("F" & Rows.Count).End(xlUp).Row
Set rng = .Range("A1:R" & lrow)
Debug.Print rng.Address
rng.AutoFilter Field:=6, Criteria1:="RECEIVED"
End With
Application.creenUpdting = True
End SubSolved.
Sub test_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim lrow As Long
Dim rRec As Range
Dim btField As Byte
Set wb = ThisWorkbook
Set ws = wb.Sheets("Intransit_")
btField = 6
Application.ScreenUpdating = False
ws.AutoFilterMode = False
With ws
lrow = .Range("F" & Rows.Count).End(xlUp).Row
Set rng = .Range("A1:R" & lrow)
With rng
.AutoFilter Field:=btField, Criteria1:="RECEIVED"
On Error Resume Next
Set rRec = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
.AutoFilterMode = False
If Not rRec Is Nothing Then
With rRec
.Columns(btField).Value = .Columns(6).Value
End With
End If
End With
Application.ScreenUpdating = True
End Sub -
Business Objects Financial Consolidation - Excel Link and VBA Macros
Hi
We use the excel links of Business Objects Financial Consolidation V10.5 to import and export data to/from BOF and excel
We used VBA macros for the imports but do not know what VBA code is required to export - this code would include the package identifier that has to be selected in the window "Select item Package "
Can anyone help?Hello Chrisitne,
I am as well intersted by the same funtiont, did you find any answer?
Can I also ask you the VBA code for Import and Export if you have it?
Thank for your help! -
I am mac user and want to create Object in VBA macro. when i write "set objwrd=createObject("Word.Application")"… it returns "runtime error "492" can't create object". now what it alternative to create object for word in excel macro???
Any help here...
http://support.microsoft.com/kb/288117
http://www.macworld.com/article/1154785/welcomebackvisualbasic.html -
How to populate internal table( varaible of ABAP table type) in Excel VBA?
Hi,
I am trying to update a database table from excel using a VBA Macro.
I am able to connect to SAP and able to read data from SAP using a RFC. Similarly after updating certain values, i want to update a table in SAP.
Below are the steps I am doing apart from basic settings.
Getting the reference of the SAP TABLE type from RFC fucntion module
' Call RFC
Set MyFunc = R3.Add("UPDATE_TVARVC_VIA_RFC")
' Get reference and Values TVARVC
Set oParam4 = MyFunc.Tables("TVARVC")
2. Loop over the active cells and populate oParam4
" add values as below
oParam4.Rows.Add
oParam4.Value(1, "NAME") = ..................
oParam4.Value(1, "TYPE") = ..................
oParam4.Value(1, "NUMB") = ..................
Do it for all columns in the table line.
My query is how to identify active cells and make the above code dynamic in step 2.
Thanks in Advance,
Best,
AneelHi Aneel,
You can try the following:
e.g.
for j = 1 to ActiveCell.SpecialCells(11).Column
oParam4.Rows.Add
if j=1 then oParam4.Value(j, "NAME") = ActiveSheet.Cells(1,j).Value
if j=2 then oParam4.Value(j, "TYPE") = ActiveSheet.Cells(1,j).Value
if j=3 then oParam4.Value(j, "NUMB") = ActiveSheet.Cells(1,j).Value
next j
Regards,
ScriptMan -
Blocked Error Messages and VBA Macros
I have a client who is in the process of migrating their Essbase 6 VBA macros to 7. Will the error messages regarding the different APIs impede upon the macros running correctly and fully?<BR><BR>I don't think this would be the case but wanted to double-check...
Hello.
I have created an dynamic Excel VBA template which include as well this log-function.
Public Function Create_Log(lngRow As Long, lngCol As Long, strLog As String)
Dim lngCounter As Long
Dim lngLast_Col As Long
Dim strLog_Line As String
lngCounter = lngRow
lngLast_Col = lngCol
strLog_Line = strLog
If ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Value = "" Then
ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Value = strLog_Line
Else
ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Value = ThisWorkbook.Sheets("SAP_PROCESS").Cells(lngCounter, lngLast_Col).Text & Chr(10) & strLog_Line
End If
End Function
In my process code I use this function like this:
'Log
If Session.FindById("wnd[0]/sbar").Text <> "" Then Create_Log lngCounter, lngLast_Col, Session.FindById("wnd[0]/sbar").Text
We can check as well if we receive an error (sy-msgty = 'E')
If Session.FindById("wnd[0]/sbar").messagetype = "E" Then Create_Log lngCounter, lngLast_Col, Session.FindById("wnd[0]/sbar").Text
Hope this give you an idea how to handle this.
Best regards,
Holger -
Hi everyone,
I have a question regarding VBA macros in BEx analyzer. I have few rows in which all values are zeros. I would like to hide such rows. I am trying to write a VBA macro to implement it. Could someone help me with this.
Thanks
RHi Ram,
I agree with Roberto that there is probably a way to do this entirely within BEx. I would try a Condition.
But ... here is what you've asked for. Note that it is written assuming that there is more than one query in the workbook and that local Query ID for this query is SAPBEXq0001. You might need to adjust these.
This code would replace (or augment) what is currently in the Module named SAPBEX.
Regards, Pete
Sub SAPBEXonRefresh(queryID As String, resultArea As Range)
'code to hide any row where all Key Figures are zero
Dim n As Integer, qRow As Integer, RowOffset As Integer
Dim ColOffset As Integer, FirstRow As Integer, FirstCol As Integer
Dim numCells As Integer, LastRow As Integer, LastCol As Integer
Dim i As Integer, KFRange As Range, HideThisRow As Boolean
Dim c As Range
If queryID = "SAPBEXq0001" Then
'locate this query's location in DIM table
Set bexWS = Sheets("SAPBEXqueries")
numQueries = bexWS.Range("A2")
For n = 1 To numQueries
If bexWS.Range("F" & n + 3) = queryID Then
qRow = n + 3
Exit For
End If
Next n
'determine Key Figures offset
RowOffset = bexWS.Range("G" & qRow)
ColOffset = bexWS.Range("H" & qRow)
'define first & last rows & columns for Key Figures
FirstRow = resultArea.Rows(RowOffset).Row
FirstCol = resultArea.Cells(ColOffset).Column
numCells = resultArea.Cells.Count
LastRow = resultArea.Cells(numCells).Row
LastCol = resultArea.Cells(numCells).Column
'search for and hide any row where all Key Figures are zero
For i = FirstRow To LastRow
Set KFRange = Range(Cells(i, FirstCol), Cells(i, LastCol))
HideThisRow = True
For Each c In KFRange.Cells
If IsNumeric(c.Value) Then
If c.Value <> 0 Then HideThisRow = False
End If
Next c
Rows(i).Hidden = HideThisRow
Next i
End If
End Sub -
Hi
Is there a commend in Excel VBA for changing the BPC Current View selections ?
Thanks in advance for your help.
KInd Regards
GavThanks for your reply, is there any way to actually change the current view itself from within VBA.
I have a sheet with many EvDREs in it, and would like my macro to cycle through selections in the current view and expand-all after each ( it then emails out the reports after each refresh ), so ideally I need to be able to change the Current View using the macro, rather than the EvCVW cells in the workbook itself.
Thanks for your help.
Maybe you are looking for
-
Password not recognised when connecting to WiFi
Hi all I have a BT Hub 5 Type A, which was installed in April. We run two small businesses from the house, so there is a lot of equipment connected to it, all by wifi. There are 4 Mac laptops, about 6 iphones, Apple TV and I run an Apple Airport netw
-
Multilingual based on client IP
Hi all, i'm newbie in adf and i'm facing problem:-- i'm making multilingual functionality on page,which is based on ip of client m/c ...based on tht it tells locale and on basis of locale .....corresponding property file will call. so on jsp page dro
-
IPhoto: Retain modified date&time details when re-importing
Instead of having all my photos in just one iPhoto library, I am now moving out photos into separate iPhoto libraries to better manage my photos: ... Export photos from existing/old library ... Re-import photos into newly-created library Some of my e
-
User Profile Service hangs for unknown reason
Hi, We have a system where usually around 300+ users are logged in simultaneously. These users are working on +-20 Windows Server 2008 R2 Terminal Servers. These servers are in a cluster. We have a physical load balancer. We have a Windows Server 200
-
Will fonts created in an earlier form (Pages/Word) show up when imported?
Hi, If i create a form in Pages/Word with eg: Century Gothic or Gill Sans and would like to import that form to Adobe Acrobat Pro to continue my form before saving it as an editable .pdf. Will the Fonts be the same then? /Sten