Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macro: Copy data from 2 dimensional array to worksheet

Status
Not open for further replies.

Nitha120

Technical User
Joined
Feb 22, 2005
Messages
33
Location
US
Hi guys,
I want to take my data and paste in a specific cell in my worksheet and repeat for all worksheet.

Example,
Take A4 from Sheet 15 and paste to a worksheet1 at E2, then take B4 from Sheet 15 and paste to worksheet1 at E3
then A5 from sheet 15 to worksheet 2 at E2 etc..
I record a macro and it give this

Sheets("Sheet15").Select
Range("A4").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("MC2A.txt").Select
Range("E2").Select
ActiveSheet.Paste
Sheets("Sheet15").Select
Range("B4").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("MC2A.txt").Select
Range("E3").Select
Selection.Copy

How can I make it to an array and able to do the same thing for all worksheet?

Any help or suggestion would be great!
thank you!
 
Hi,
Code:
    Sheets("Sheet15").Range("A4:B4").Copy _
        Sheets("MC2A.txt").Range("E2")



Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Hi Skip,

Your codes:

Sheets("Sheet15").Range("A4:B4").Copy _
Sheets("MC2A.txt").Range("E2")

How can it be modify so that the next Range (A5:B5)from Sheet15 is paste to the next worksheet which is sheet
"MC3A.TXT".

Is there a For loop i can use if so where would i start it.
thank!
 
Code:
    Sheets("Sheet15").Range("A4:B5").Copy _
        Sheets("MC2A.txt").Range("E2")

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Something like this ?
For i = 4 To 5
Sheets("Sheet15").Range("A" & i & ":B" & i).Copy _
Sheets("MC" & (i - 2) & "A.txt").Range("E2")
Next i

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top