Sending Data from one spreadsheet to multiple speadsheets

[Closed]
Report
-
Posts
2779
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
July 29, 2021
-
Hello,

I am fairly new to VBA and have been searching for a solution for my problem but as yet have not managed to find one.

I wish to send data from one spread sheet to multiple sheets depending upon the number given in column A which would match to the worksheet name to send to.

The multiple spread sheets will be named numerically from 1 onwards and would accumulate overtime, I am wanting all the data in column B to be sent to its relevant worksheet which will named in column A.

Please can you let me know if this is possible.

Many thanks in advance



1 reply

Posts
2779
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
July 29, 2021
468
Hi Pwaluk,

Yes, this is possible.

The code below puts the value found in column B in the sheet mentioned in column A in column B.

Sub RunMe()
Dim MySheet As String
For Each cell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
    MySheet = cell.Value
    Sheets(MySheet).Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = _
    cell.Offset(0, 1).Value
Next cell
End Sub


Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!