Help with VBA

Chrisw706

New Member
Joined
Jun 16, 2011
Messages
1
I am very new to VBA and could use some help. I have been searching and searching and I am lost on how to solve my problem.

In Sheet1 I have four columns. There are titled DATE(A), SOURCE(B), DESTINATION(c), MESSAGE(D)

Each cell under the source and Destination columns contains a phone number. I may have 1000 or more rows and there may be 30 (sometimes more) unique numbers that are listed in both source and destination columns. I have a differant worksheet for each of those unique numbers and each sheet is named by that number.

What I need to is to take the sheet name and if that name is equal to the value of the cell in the Source or Destination (this number will not be in both only one or the other) column copy the whole row and paste it into the the sheet with the coresponding name and continue down the sheet until I have reached the first blank cell. Once that is done move onto the next sheet and do the same thing with that sheet and so on.

Thank You very much

Chris
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi Try this code.

Sub copydetails()
Dim i As Integer
Dim a As String
For i = 1 To Sheets.Count
Sheets(i).Select
a = ActiveSheet.Name
Sheets("Sheet1").Select
Range("B1").Select
Do Until ActiveCell.Row = Range("A65536").End(xlUp).Offset(1, 0).Row
If ActiveCell.Value = a Or ActiveCell.Offset(0, 1).Value = a Then
ActiveCell.EntireRow.Copy
Sheets(a).Select
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Sheets("Sheet1").Select
ActiveCell.Offset(1, 0).Select
Loop
Next
End Sub
 
Upvote 0
Hi guarav23,

your code is probably good, but for easier readability could you place it between code tags

that is, put [ code ] (but without the spaces) at start of your code and [/code] at end of code. then use the preview button to check that it's OK

thanks

would make me and probably everyone else very happy
 
Upvote 0
Hi Thanks for telling me...I wasn't knowing how to put a code into that.

From next time onwards will follow the same.

Thanks,
Gaurav
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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