VBA: Change referenced cell for each loop iteration

yits05

Board Regular
Joined
Jul 17, 2020
Messages
56
Office Version
  1. 2016
Platform
  1. Windows
Let me start by saying I am completely new to VBA. I have the following code (dumbed down version of the actual code but captures the essence of my question):

VBA Code:
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To FinalRow
    Sheets("Sheet1").Select
    Range("A2").Select
    Selection.Copy
    Sheets("Sheet1B2").Paste

Next i

It's purpose is to copy cell content from A2 to B2, A3 to B3, and so on for 175 rows. I know I am doing something wrong because there is nothing telling Excel to change the cell reference with each loop. Would appreciate any guidance on how to do this.

Thanks!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi
VBA Code:
For i = 2 To FinalRow
    Sheets("Sheet1").Select
    Range("A" & i).Select
    Selection.Copy
    Sheets("Sheet1").Range("B" & i).Paste

Next i
 
Upvote 0
Solution
And try this as well
VBA Code:
For i = 2 To FinalRow
    Sheets("Sheet1").  Range("A" & i).Copy  Sheets("Sheet1").Range("B" & I)

Next i
 
Upvote 0
Or without a loop
VBA Code:
   With Sheets("Sheet1")
      .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Copy .Range("B2")
   End With
 
Upvote 0

Forum statistics

Threads
1,214,620
Messages
6,120,554
Members
448,970
Latest member
kennimack

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