ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   New try, Help needed (https://www.excelbanter.com/excel-programming/364787-new-try-help-needed.html)

miikka1978

New try, Help needed
 

I have 110 ranges that I have labeled (A1,A2,A3...A110). First, I would
like to select A1 and perform a certain task, and then I would like to
select A2 and perform the same task. The problem is that I don't know
how to write a code that uses for-loop to do the task for all the 110
ranges. Here you can see the code that I was able to create by
recording the macro. Could someone help me with this piece of code?

Sub AT()

Application.Goto Reference:="A1"
Selection.Copy
Sheets("AS").Select
Range("A63").Select
ActiveSheet.Paste
Application.Run "'Excel 7.0.xls'!TS"
Application.Run "'Excel 7.0.xls'!TT"
Application.Goto Reference:="A2"
Selection.Copy
Sheets("AS").Select
Range("A63").Select
ActiveSheet.Paste
Application.Run "'Excel 7.0.xls'!TS"
Application.Run "'Excel 7.0.xls'!TT"
End Sub


--
miikka1978
------------------------------------------------------------------------
miikka1978's Profile: http://www.excelforum.com/member.php...o&userid=32294
View this thread: http://www.excelforum.com/showthread...hreadid=553510


[email protected]

New try, Help needed
 
Not that I'd probably do it this way but...


Sub AT()
for looper=1 to 110
Application.Goto Reference:="A"& trim(str(looper))
Selection.Copy
Sheets("AS").Select
Range("A63").Select
ActiveSheet.Paste
Application.Run "'Excel 7.0.xls'!TS"
Application.Run "'Excel 7.0.xls'!TT"
next
end sub

miikka1978 wrote:
I have 110 ranges that I have labeled (A1,A2,A3...A110). First, I would
like to select A1 and perform a certain task, and then I would like to
select A2 and perform the same task. The problem is that I don't know
how to write a code that uses for-loop to do the task for all the 110
ranges. Here you can see the code that I was able to create by
recording the macro. Could someone help me with this piece of code?

Sub AT()

Application.Goto Reference:="A1"
Selection.Copy
Sheets("AS").Select
Range("A63").Select
ActiveSheet.Paste
Application.Run "'Excel 7.0.xls'!TS"
Application.Run "'Excel 7.0.xls'!TT"
Application.Goto Reference:="A2"
Selection.Copy
Sheets("AS").Select
Range("A63").Select
ActiveSheet.Paste
Application.Run "'Excel 7.0.xls'!TS"
Application.Run "'Excel 7.0.xls'!TT"
End Sub


--
miikka1978
------------------------------------------------------------------------
miikka1978's Profile: http://www.excelforum.com/member.php...o&userid=32294
View this thread: http://www.excelforum.com/showthread...hreadid=553510



miikka1978[_2_]

New try, Help needed
 

Thank you for such a quick repply.


--
miikka1978
------------------------------------------------------------------------
miikka1978's Profile: http://www.excelforum.com/member.php...o&userid=32294
View this thread: http://www.excelforum.com/showthread...hreadid=553510



All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com