Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
New to Excel VBA. The following does not return the current active cell
but returns error 91. Sub Macro1() ' ' Macro1 Macro ' Dim rangeCurrentCell As Range ' rangeCurrentCell = ActiveCell 'more stuff The defn. of ActiveCell is confusing me. All I want is the currently selected in A1 type format. Thanks. Thomas |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thomas, It lloks as if you are lloking for : ActiveCell.Address
This will return $H$7 if the cursor is on cell H7. -- Regards, Auk Ales * Please reply to this newsgroup only * * I will not react on unsolicited e-mails * "Thomas" wrote in message ... New to Excel VBA. The following does not return the current active cell but returns error 91. Sub Macro1() ' ' Macro1 Macro ' Dim rangeCurrentCell As Range ' rangeCurrentCell = ActiveCell 'more stuff The defn. of ActiveCell is confusing me. All I want is the currently selected in A1 type format. Thanks. Thomas |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thomas,
Object variables are assigned with the Set command Set rangeCurrentCell = ActiveCell -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Thomas" wrote in message ... New to Excel VBA. The following does not return the current active cell but returns error 91. Sub Macro1() ' ' Macro1 Macro ' Dim rangeCurrentCell As Range ' rangeCurrentCell = ActiveCell 'more stuff The defn. of ActiveCell is confusing me. All I want is the currently selected in A1 type format. Thanks. Thomas |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perhaps I am being dense (wouldn't be the first time). However, this
code still gives the same error (Run time error '91': Object variable or With block variable not set) Sub Macro1() ' ' Macro1 Macro ' Dim rangeCurrentCell As Range ' rangeCurrentCell = ActiveCell.Address ' more stuff… If fails at the rangeCurrentCell = ActiveCell.Address line. The other solution, "Set rangeCurrentCell = ActiveCell" fails the same way. What am I missing? This should not be that hard. Thanks. Best regards, Thomas Bob Phillips wrote: Thomas, Object variables are assigned with the Set command Set rangeCurrentCell = ActiveCell |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thomas,
You are mixing types up. You declare rangeCurrentCell as a range, but then try to use it as a variable and assign it a string value. This works Dim rangeCurrentCell As String ' rangeCurrentCell = ActiveCell.Address I am also surprised to hear you say that Set rangeCurrentCell = ActiveCell it certainly works for me as long as rangeCurrentCell is declared as range or variant. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Thomas" wrote in message ... Perhaps I am being dense (wouldn't be the first time). However, this code still gives the same error (Run time error '91': Object variable or With block variable not set) Sub Macro1() ' ' Macro1 Macro ' Dim rangeCurrentCell As Range ' rangeCurrentCell = ActiveCell.Address ' more stuff… If fails at the rangeCurrentCell = ActiveCell.Address line. The other solution, "Set rangeCurrentCell = ActiveCell" fails the same way. What am I missing? This should not be that hard. Thanks. Best regards, Thomas Bob Phillips wrote: Thomas, Object variables are assigned with the Set command Set rangeCurrentCell = ActiveCell |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oi! Thanks, Bob. Got off on the wrong track and couldn't see it. Not
sure about the rangeCurrentCell = ActiveCell. I will look further into it. Thomas Bob Phillips wrote: Thomas, You are mixing types up. You declare rangeCurrentCell as a range, but then try to use it as a variable and assign it a string value. This works Dim rangeCurrentCell As String ' rangeCurrentCell = ActiveCell.Address I am also surprised to hear you say that Set rangeCurrentCell = ActiveCell it certainly works for me as long as rangeCurrentCell is declared as range or variant. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to find cell content in sheets and make sheet active | Excel Discussion (Misc queries) | |||
Row select mode to highlight active row of active cell | Excel Discussion (Misc queries) | |||
Find last cell in a column, Delete its contents and make it active | Excel Worksheet Functions | |||
Find address of active cell | Excel Worksheet Functions | |||
copy active cell value,find the pasted value in different worksheet | Excel Worksheet Functions |