Elknoxious
New Member
- Joined
- Oct 25, 2016
- Messages
- 8
I'm stuck on a problem and hoping for some help.
I am trying to use a variable as a range argument. My goal is to loop through a range of values in another worksheet and when a value is reached copy that row and paste it to another worksheet.
The row contains several formats including a link to a webpage.
Sheetname simply designates the corresponding sheet name based on user input.
What I know works:
However, I would like to input variables into the range argument in Sheetname.
I've tried to create string variables:
and
When I print the variables they look correct but I get an error: " Run-time error '1004': " etc.
I've also tried using range and cells together but without success.
I would be grateful of any information regarding what I am doing wrong.
Thank you MrExcel community.
I am trying to use a variable as a range argument. My goal is to loop through a range of values in another worksheet and when a value is reached copy that row and paste it to another worksheet.
The row contains several formats including a link to a webpage.
Sheetname simply designates the corresponding sheet name based on user input.
What I know works:
Code:
Worksheets(SheetName).Range("B4:H4").Copy
Worksheets("Calculation").Range("A28:G28").PasteSpecial Paste:=xlPasteAll
However, I would like to input variables into the range argument in Sheetname.
I've tried to create string variables:
Code:
minRow = "B" & irow
maxRow = "H" & irow
and
Code:
Worksheets(SheetName).Range("minRow:maxRow").Copy
Worksheets("Calculation").Range("A28:G28").PasteSpecial Paste:=xlPasteAll
When I print the variables they look correct but I get an error: " Run-time error '1004': " etc.
I've also tried using range and cells together but without success.
I would be grateful of any information regarding what I am doing wrong.
Thank you MrExcel community.
Last edited: