Pasting Data into Sheets via VBA

t01te6

Board Regular
Joined
Apr 3, 2008
Messages
93
Hey I have a simple table which has the worksheet name in Column A and then several codes (text) in columns B to AA,

Is it possible to get a bit of Code which will take all the data in column B and so on and put it into the worksheet that is in Column A,

There is already data in the other worksheets so could it be fixed so that the new data will go into column B after the data thats already there.

I thank you for your help

Tim
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
sheet 1 column A has the sheet names
you want this to go into sheet 2

copy your file and do this so that original data is not messed up
in the copied file copy this macro
data in sheet from col b to the right is copied in sheet 2 . see sheet 2.
give feedback.

Code:
Sub test()
Dim sh As String
With Worksheets("sheet1")
Range(.Range("b1"), .Range("b1").End(xlToRight).End(xlDown)).Copy
sh = Selection.Value
If Selection.Column > 1 And Selection = "" Then MsgBox "the sheet is not selected"
Worksheets(sh).Activate
Cells(Rows.Count, "a").End(xlUp).Offset(1, 0).PasteSpecial
End With
Application.CutCopyMode = False
End Sub
 
Upvote 0
Hey,

Thank you very much for your help, Unfortunatly when I put the code in nothing seems to happen. The page flicks to the first worksheet in A1 and put a few what appears to be random codes in there, but nothing happens on the next sheets.

Can you help? Am I perhaps doing something wrong?

Thanks

Tim
 
Upvote 0
1. where did you park the macro
2. didi you select any cell in column A of sheet1 before runnng the macro.
 
Upvote 0
try
Code:
Sub test()
If Not TypeOf Selection Is Range Then Exit Sub
Selection.EntireRow.Copy
With Sheets(Selection.EntireRow.Cells(1).Value)
    .Cells(.Cells.SpecialCells(11).Row + 1, "a").PasteSpecial
End With
Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top