Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Calculate,Copy, Paste Cell Group

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Calculate,Copy, Paste Cell Group

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Calculate,Copy, Paste Cell Group

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Calculate,Copy, Paste Cell Group

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Calculate,Copy, Paste Cell Group

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Calculate,Copy, Paste Cell Group

works like a charm.....thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Calculate,Copy, Paste Cell Group

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Calculate,Copy, Paste Cell Group

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
large file - copy and paste small group CHEL294 Excel Discussion (Misc queries) 2 June 4th 09 09:08 PM
Copy data and paste to different sheet named on Group Prem Excel Discussion (Misc queries) 1 February 21st 08 02:56 PM
Calculate, Copy, Paste [email protected] Excel Programming 6 November 16th 05 01:44 PM
vba to sort group copy paste to another sheet tango Excel Programming 1 November 5th 04 08:08 AM
vba to sort group copy paste to another sheet mango Excel Worksheet Functions 0 November 5th 04 04:27 AM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"