Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Need help with a macro I can not for some reason get to work what I am
trying to do is copy cells "AF78:AJ78" and then do a copy, paste special to "AF81:AJ81" and then calculate "rand() " and copy "AF78:AJ78" again and then paste special to column AF82:AJ82 and then repeat the same procedure 10, 50, 200 times if wanted. I have no problem editing the macro for the number of times I want to calculate, copy and paste. Thanks in Advance Sub afpaste() Dim rng As Range, i As Long, j As Dim cell As Range, n As Long, v(1 To 5) As String Dim s As Long s = Applicaton.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, v(j)).Value = cell.Value Next Next Application.Calculate = s End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Depending on what the formula is in AF78:AJ78 it looks like you could do it
all in one go: With Range("AF81:AJ105") .Formula = "=Rand() * 10" .Formula = .Value End With Cheers, Dave " wrote: Need help with a macro I can not for some reason get to work what I am trying to do is copy cells "AF78:AJ78" and then do a copy, paste special to "AF81:AJ81" and then calculate "rand() " and copy "AF78:AJ78" again and then paste special to column AF82:AJ82 and then repeat the same procedure 10, 50, 200 times if wanted. I have no problem editing the macro for the number of times I want to calculate, copy and paste. Thanks in Advance Sub afpaste() Dim rng As Range, i As Long, j As Dim cell As Range, n As Long, v(1 To 5) As String Dim s As Long s = Applicaton.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, v(j)).Value = cell.Value Next Next Application.Calculate = s End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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") rng.Formula = "=rand()" 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 seemed to work for me. -- Regards, Tom Ogilvy wrote in message ups.com... Need help with a macro I can not for some reason get to work what I am trying to do is copy cells "AF78:AJ78" and then do a copy, paste special to "AF81:AJ81" and then calculate "rand() " and copy "AF78:AJ78" again and then paste special to column AF82:AJ82 and then repeat the same procedure 10, 50, 200 times if wanted. I have no problem editing the macro for the number of times I want to calculate, copy and paste. Thanks in Advance Sub afpaste() Dim rng As Range, i As Long, j As Dim cell As Range, n As Long, v(1 To 5) As String Dim s As Long s = Applicaton.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, v(j)).Value = cell.Value Next Next Application.Calculate = s End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
sorry dave and tom the formula in AF78:AJ78 is a sum of a preexisting
numbers that change every time the sheet caclulates. all i was trying to do is copy and paste the results of "AF78:AJ78" which has the formula "SUM in AF78 to AJ78 then calulate sheet and repeat the copy and paste down 10,20, 50, 100 times depending on what ever amount i place in the macro..sorry for the misunderstanding |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I fixed your code to do that. I just added the rand() line for testing.
Take it out and your formula should work 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 -- Regards, Tom Ogilvy wrote in message oups.com... sorry dave and tom the formula in AF78:AJ78 is a sum of a preexisting numbers that change every time the sheet caclulates. all i was trying to do is copy and paste the results of "AF78:AJ78" which has the formula "SUM in AF78 to AJ78 then calulate sheet and repeat the copy and paste down 10,20, 50, 100 times depending on what ever amount i place in the macro..sorry for the misunderstanding |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
works like a charm.....thanks
|
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
tom i also was hoping to make changes to the macro so i could use it to
copy and paste 6 numbers in another workbook and 4 numbers in still another workbook and do the same thing but for some reason it will not work. here are the changes i made to your macro thinking it would run in the 6 number workbook 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 Tom Ogilvy wrote: I fixed your code to do that. I just added the rand() line for testing. Take it out and your formula should work 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 -- Regards, Tom Ogilvy wrote in message oups.com... sorry dave and tom the formula in AF78:AJ78 is a sum of a preexisting numbers that change every time the sheet caclulates. all i was trying to do is copy and paste the results of "AF78:AJ78" which has the formula "SUM in AF78 to AJ78 then calulate sheet and repeat the copy and paste down 10,20, 50, 100 times depending on what ever amount i place in the macro..sorry for the misunderstanding |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
tom i also was hoping to make changes to the macro so i could use it to
copy and paste 6 numbers in another workbook and 4 numbers in still another workbook and do the same thing but for some reason it will not work. here are the changes i made to your macro thinking it would run in the 6 number workbook 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
large file - copy and paste small group | Excel Discussion (Misc queries) | |||
Copy data and paste to different sheet named on Group | Excel Discussion (Misc queries) | |||
Calculate, Copy, Paste | Excel Programming | |||
vba to sort group copy paste to another sheet | Excel Programming | |||
vba to sort group copy paste to another sheet | Excel Worksheet Functions |