Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default VBA 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default VBA question

maybe try something like this, i wouldn't use p$ as a variable.

Sub test()
Dim c As Range
Dim pstr As String
pstr = "C3:C20"
With Worksheets("Stats")
For Each c In .Range(pstr)
Debug.Print c.Value
Next
End With
End Sub

--


Gary


"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   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default VBA question

With regards to your original code, I think you want .Cells instead of .Range

With Worksheets("Stats").Range(p$)

For Each c In .Cells
Debug.Print c.Value
Next

End With


"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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"