stata_user
New Member
- Joined
- Mar 6, 2018
- Messages
- 2
Hi everyone,
I'm new here (thanks for having me) and am a novice user of Excel. I'm struggling with what I'm sure are basic looping issues in VBA, and am hoping that someone could direct me to a useful instructional website or perhaps be kind enough to help me get started in loops.
Some details: I have approximately 3,000 observations across two worksheets (1990, 2000) that need to be copied into a master file. After they have been pasted into this master file (Sheet 1, values are then adjusted), I need to yet again transpose newly adjusted values into another worksheet (Sheet 3). So, really, I need to repeat the copy/paste process for all 3,00 observations.
In the event anyone finds this helpful, I've pasted one successful iteration of this process, but I'm at a loss of how to loop over this mess.
Any advice is greatly appreciated!
Sheets("1990").Select
Range("A2:R2").Select
Selection.Copy
Sheets("Sheet1").Select
Range("D12:D28").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Sheets("2000").Select
Range("A3:AU3").Select
Selection.Copy
Sheets("Sheet1").Select
Range("I11:I57").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Sheets("2000").Select
Range("AV3:CP3").Select
Selection.Copy
Sheets("Sheet1").Select
Range("J11:J57").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Range("J177:J222").Select
Selection.Copy
Sheets("Sheet3").Select
Range("B3:AU3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Sheets("Sheet1").Select
Range("K177:K222").Select
Selection.Copy
Sheets("Sheet3").Select
Range("AW3:CP3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
End Sub
I'm new here (thanks for having me) and am a novice user of Excel. I'm struggling with what I'm sure are basic looping issues in VBA, and am hoping that someone could direct me to a useful instructional website or perhaps be kind enough to help me get started in loops.
Some details: I have approximately 3,000 observations across two worksheets (1990, 2000) that need to be copied into a master file. After they have been pasted into this master file (Sheet 1, values are then adjusted), I need to yet again transpose newly adjusted values into another worksheet (Sheet 3). So, really, I need to repeat the copy/paste process for all 3,00 observations.
In the event anyone finds this helpful, I've pasted one successful iteration of this process, but I'm at a loss of how to loop over this mess.
Any advice is greatly appreciated!
Sheets("1990").Select
Range("A2:R2").Select
Selection.Copy
Sheets("Sheet1").Select
Range("D12:D28").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Sheets("2000").Select
Range("A3:AU3").Select
Selection.Copy
Sheets("Sheet1").Select
Range("I11:I57").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Sheets("2000").Select
Range("AV3:CP3").Select
Selection.Copy
Sheets("Sheet1").Select
Range("J11:J57").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Range("J177:J222").Select
Selection.Copy
Sheets("Sheet3").Select
Range("B3:AU3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Sheets("Sheet1").Select
Range("K177:K222").Select
Selection.Copy
Sheets("Sheet3").Select
Range("AW3:CP3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
End Sub