![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Singapore
Posts: 77
|
Urgent!
Could any one tell whether there is a limit on the number of variables in Range(). I have the following codes: Worksheets("sheet1").Activate Range(Cells(iShift * 21 - 16, iCol), Cells(iShift * 21 - 5), iCol).ClearContents But it always pops up a message to tell me "Compile Error. Wrong Number of arguments or invalid property assignment" Could you fix this problem for me. Thanx regards Andrew XJ |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
as the open brackets count "(" should match the closed bracket count ")" Range(Cells(iShift * 21 - 16, iCol), Cells(iShift * 21 - 5), iCol)).ClearContents Ivan |
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Singapore
Posts: 77
|
I use VB Editor. The "(" and ")" are paired. I have checked that.
I don't know whether the number of parameters can be used in Cells() if Cells() itself is property of Range(). Or any other problems. I have declared the variables. |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
should be; Range(Cells(iShift * 21 - 16, iCol), Cells(iShift * 21 - 5, iCol)).ClearContents Ivan |
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Singapore
Posts: 77
|
Thx. Now it works. The number is correct, but the positions are not correct.
This is a problem about Range again. So sorry to trouble you again. Code: weekRow = Range("A302:A353").Find(what:=week, lookAt:=xlWhole, searchOrder:=xlByColumns).Row The error message: Object Variable or With Block variable not Set. I have selected both worksheet and the range. |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Dim weekRow as range dim iWkRow as double set weekRow = Range("A302:A353").Find(what:=week, lookAt:=xlWhole, searchOrder:=xlByColumns) iWkRow = weekRow.Row you will probably need an error handling routine incase nothing is found in which case the variable weekRow = Nothing Ivan |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|