For Loop with multiple condition

bcmk29

Board Regular
Joined
Oct 20, 2022
Messages
55
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Here's my code to copy the range available in SH and paste it into A1. This works fine for the first time, for the second time code pastes the copied value in A1 again I need that to be looped as B1, C1, D1..etc Please help.

VBA Code:
SH = ThisWorkbook.Worksheets(4).Cells(Rows.Count, 19).End(xlUp).Row - 1
For A = 2 To SH
    Importworkbook.Worksheets(1).Range(Sheets("Sheet3").Range("T" & A).Value).Copy ThisWorkbook.Worksheets(2).Range("[B]A1[/B]")
Next A
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You will want to replace

.Range("A1")

with

.Cells(1, A-1)
 
Upvote 0
Solution
Thanks, that was quick and it works as I expected.

Here's the thread for my next question.
 
Upvote 0

Forum statistics

Threads
1,216,112
Messages
6,128,901
Members
449,477
Latest member
panjongshing

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