For-Next/Cells Syntax help

jsolomon

Board Regular
Joined
Mar 25, 2005
Messages
109
Hi guys,
I am still trying to grasp the for-each-next logic, but it seems that I am sttill having trouble. The code I am trying to write this time will take the text in rows 16-60 & cols a-h on sheet-Invoice and copy it to the log worksheet. Here is my code. Any help is greatly appreciated.
Code:
      For SourceRow = 16 To 60
          Set SourceRange = ActiveWorkbook.Sheets("invoice").Range("Cells(SourceRow,1):Cells(SourceRow,8)")
          ActiveWorkbook.Sheets("log").Range("a1").Value = SourceRange
     Next SourceRow

Thanks,

Joe
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about?
Code:
For SourceRow = 16 To 60
    Set SourceRange = ActiveWorkbook.Sheets("invoice").Range(Cells(SourceRow, 1), Cells(SourceRow, 8))
    SourceRange.Copy _
        Destination:=ActiveWorkbook.Sheets("log").Range("a" + SourceRow - 15)
Next SourceRow
 
Upvote 0
Joe

Are you sure you need a loop here?
Code:
ActiveWorkbook.Sheets("invoice").Range("A16:H60").Copy
ActiveWorkbook.Sheets("log").Range("a1").PasteSpecial xlPasteValues
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top