Calculate,Copy, Paste Cell Group Macro Adjustments

B

boblinda11

Tom Ogilvy was so kind to help me with the below macro which works
great for copy and paste 5 number workbook but having a problem
applying it to 6 number and 4 number workbook I was hoping to make
changes to the macro so i could use it to
copy and paste in workbooks with 6 numbers and another workbook with 4
numbers so it would run the same way but for some reason it will not
work.

here are the changes i made to Tom's macro thinking it would run in
the 6 number workbook but does not run
Dim cell As Range, n As Long, v(1 To ""6"") As String
v(4) = "AI": v(5) = "AJ" "": v(6) = "AK" ""
could you please tell me what i am missing to make it run....thanks

Here is Toms macro that works fine with 5 number workbook
Sub afpaste()
Dim rng As Range, i As Long, j As Long
Dim cell As Range, n As Long, v(1 To 5) As String
Dim s As Long
s = Application.Calculation
Application.Calculation = xlManual
n = 25
Set rng = Range("AF78:AJ78")
v(1) = "AF": v(2) = "AG": v(3) = "AH"
v(4) = "AI": v(5) = "AJ"
For i = 1 To n
Application.Calculate
j = 0
For Each cell In rng
j = j + 1
Cells(i + 80, v(j)).Value = cell.Value
Next
Next
Application.Calculation = s
End Sub
 
K

Ken Johnson

Hi,
I guessing....

Sub afpaste4()
Dim rng As Range, i As Long, j As Long
Dim cell As Range, n As Long, v(1 To 4) As String
Dim s As Long
s = Application.Calculation
Application.Calculation = xlManual
n = 25
Set rng = Range("AF78:AI78")
v(1) = "AF": v(2) = "AG": v(3) = "AH"
v(4) = "AI"
For i = 1 To n
Application.Calculate
j = 0
For Each cell In rng
j = j + 1
Cells(i + 80, v(j)).Value = cell.Value
Next
Next
Application.Calculation = s
End Sub

for 4 number workbook, and...

Sub afpaste6()
Dim rng As Range, i As Long, j As Long
Dim cell As Range, n As Long, v(1 To 6) As String
Dim s As Long
s = Application.Calculation
Application.Calculation = xlManual
n = 25
Set rng = Range("AF78:AK78")
v(1) = "AF": v(2) = "AG": v(3) = "AH"
v(4) = "AI": v(5) = "AJ": v(6) = "AK"
For i = 1 To n
Application.Calculate
j = 0
For Each cell In rng
j = j + 1
Cells(i + 80, v(j)).Value = cell.Value
Next
Next
Application.Calculation = s
End Sub

for 6 number workbook.

Ken Johnson
 
T

Tom Ogilvy

Sub afpaste6()
Dim rng As Range, i As Long, j As Long
Dim cell As Range, n As Long, v(1 To 6) As String
Dim s As Long
s = Application.Calculation
Application.Calculation = xlManual
n = 25
Set rng = Range("AF78:AK78")
v(1) = "AF": v(2) = "AG": v(3) = "AH"
v(4) = "AI": v(5) = "AJ" : v(6) = "AK"
For i = 1 To n
Application.Calculate
j = 0
For Each cell In rng
j = j + 1
Cells(i + 80, v(j)).Value = cell.Value
Next
Next
Application.Calculation = s
End Sub

------------

Sub afpaste4()
Dim rng As Range, i As Long, j As Long
Dim cell As Range, n As Long, v(1 To 4) As String
Dim s As Long
s = Application.Calculation
Application.Calculation = xlManual
n = 25
Set rng = Range("AF78:AI78")
v(1) = "AF": v(2) = "AG": v(3) = "AH"
v(4) = "AI"
For i = 1 To n
Application.Calculate
j = 0
For Each cell In rng
j = j + 1
Cells(i + 80, v(j)).Value = cell.Value
Next
Next
Application.Calculation = s
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top