Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA basic question
I should know why this doesn't work...but
get 'Wrong number of arguments or invalid property assignment' and can't resolve it. With Worksheets("Stats").Range(p$) For Each c In .Range Debug.Print c.Value Next End With The value of p$ is "C3:C20" Many thanks - Kirk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA basic question
You cannot name a range p$ try this.....
Dim p As Range, c As Range Set p = Range("C3:C20") With Worksheets("Stats") For Each c In p Debug.Print c.Value Next End With -- Cheers Nigel "kirkm" wrote in message ... I should know why this doesn't work...but get 'Wrong number of arguments or invalid property assignment' and can't resolve it. With Worksheets("Stats").Range(p$) For Each c In .Range Debug.Print c.Value Next End With The value of p$ is "C3:C20" Many thanks - Kirk |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA basic question
kirkm, You are doing the range thing twice; this will work:
Sub MacroTaDa() Dim p$ p$ = "C3:C20" With Worksheets("Stats") For Each c In .Range(p$) Debug.Print c.Value Next End With End Sub "kirkm" wrote: I should know why this doesn't work...but get 'Wrong number of arguments or invalid property assignment' and can't resolve it. With Worksheets("Stats").Range(p$) For Each c In .Range Debug.Print c.Value Next End With The value of p$ is "C3:C20" Many thanks - Kirk |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA basic question
Or this will work:
Sub MacroTaDa2() Dim p$ p$ = "C3:C20" For Each c In Worksheets("Stats").Range(p$) Debug.Print c.Value Next End Sub "kirkm" wrote: I should know why this doesn't work...but get 'Wrong number of arguments or invalid property assignment' and can't resolve it. With Worksheets("Stats").Range(p$) For Each c In .Range Debug.Print c.Value Next End With The value of p$ is "C3:C20" Many thanks - Kirk |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA basic question
With Worksheets("Stats").Range(p$)
For Each c In .Range Hi. You have answers from others. Just to point out, your method would work if you drilled one level down ie. "Cells" instead of "Range." Sub Demo() Dim P$ Dim C As Range P$ = "C3:C20" With Worksheets("Stats").Range(P$) For Each C In .Cells Debug.Print C.Value Next End With End Sub -- HTH :) Dana DeLouis Windows XP & Office 2003 "kirkm" wrote in message ... I should know why this doesn't work...but get 'Wrong number of arguments or invalid property assignment' and can't resolve it. With Worksheets("Stats").Range(p$) For Each c In .Range Debug.Print c.Value Next End With The value of p$ is "C3:C20" Many thanks - Kirk |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA basic question
Please don't multipost.
http://www.cpearson.com/excel/newposte.htm "kirkm" wrote: I should know why this doesn't work...but get 'Wrong number of arguments or invalid property assignment' and can't resolve it. With Worksheets("Stats").Range(p$) For Each c In .Range Debug.Print c.Value Next End With The value of p$ is "C3:C20" Many thanks - Kirk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Very basic VBA question. | Excel Discussion (Misc queries) | |||
basic question | New Users to Excel | |||
Basic VBA Question | Excel Programming | |||
Basic question | Excel Discussion (Misc queries) | |||
Basic VBA question | Excel Programming |