michaeltsmith93
Board Regular
- Joined
- Sep 29, 2016
- Messages
- 83
I have two sheets, A and B. Sheet A is a master list of people with data in each person's row corresponding to that person. I've written a userform that allows me to move people's row of data from A to B.
We're still in the preliminary stages of our project, so columns are being added to A sporadically. I want to reflect these changes on B, but I don't want to use Worksheet Change because I don't want to lose Undo, so I'm planning to add the code to the userform button that moves the rows. What's the best way to go about adding the new columns from A to B? My goal is that a person on A can't be moved to B via the button without first reconciling the columns.
I should add that it's very unlikely that columns will be deleted, and if they are, I can do that manually.
I imagine it will be something like:
We're still in the preliminary stages of our project, so columns are being added to A sporadically. I want to reflect these changes on B, but I don't want to use Worksheet Change because I don't want to lose Undo, so I'm planning to add the code to the userform button that moves the rows. What's the best way to go about adding the new columns from A to B? My goal is that a person on A can't be moved to B via the button without first reconciling the columns.
I should add that it's very unlikely that columns will be deleted, and if they are, I can do that manually.
I imagine it will be something like:
Code:
Dim SheetA as Worksheet
Dim SheetB as Worksheet
Dim LastColumn As Long
LastColumn = range.find().column
Set SheetA = "A"
Set SheetB = "B"
For i = 1 to LastColumn
If SheetA.Cells(4, i) <> SheetB.Cells(4, i) Then
SheetB.Cells(4, i+1).Insert
SheetB.Cells(4, i+1).Value = SheetA.Cells(4, i).Value
End If
Next