PDA

View Full Version : Solved: Repeat Column Insertation (It's simple!)



Phelony
04-20-2009, 08:50 AM
Hi guys :hi:

It's late, I'm tired and I know this is a simple one, but could someone please help me sort this out.

' InsertKYC Macro
'
Dim j As Integer

Dim range As Integer
For j = to Sheets ("Input KYC Sheet")Range("D247").


Sheets("KYC Checklist").Select
Rows("19:19").Select
Selection.Copy
Selection.Insert Shift:=xlDown
Next j
End Sub

All I'm trying to do is to get it to copy and insert Row 19 on the KYC Checklist sheet the number of times that the Input KYC Sheet has in cell D247. :bug:

I can't get it to recognise the range....:mkay

I know this isn't difficult :rtfm:but my brain is fried and i can't take VBA yelling "expected bracket or expression" at me anymore. :stars:

Thanks

Phel x

MaximS
04-20-2009, 09:04 AM
try that:


Dim i, j As Integer

With Worksheets("Input KYC Sheet")

j = .Range("D247").Value

For i = 1 To j

.Select
.Rows("19:19").Select
Selection.Copy
Selection.Insert Shift:=xlDown
Next j

End With
End Sub

Phelony
04-20-2009, 09:16 AM
A couple of minor changes but thank you so much for coming up with the right code. :cloud9: My poor old head couldn't take much more! :banghead:

Ended up with

'
Dim i, j As Integer

With Worksheets("Input KYC Sheet")

j = .range("D247").Value

For i = 1 To j

Sheets("KYC Checklist").Select
Rows("19:19").Select
Selection.Copy
Selection.Insert Shift:=xlDown
Next i

End With
End Sub

Thanks for the help :hi: