obiwilson
New Member
- Joined
- Jul 25, 2015
- Messages
- 17
I realize this question is similar to what is being asked here and here. However, when I tried to adapt them for my use I ran into several issues.
On worksheet "Free IDs" I have Table1 from A1:J21 with headers, data validation and formulas.
On worksheet "MASTER LIST" I have Table2 with the same headers and no data atm (I removed all the historical data as it was a mess)
There is a button on the bottom of worksheet "FREE IDs" which needs to perform the following:
- copy data from Table1 (minus the header) to the end of Table2.
- clear data from Table1 from B2:J21 but keep data validation, formulas and set background to no fill color.
or
- clear data from Table1 keeping data validation, formulas, set background to no fill and repopulate column A (A2:A21) with sequential numbers carrying on from what was cleared. So the previous A21+1 would be the new A2...
I have managed to do this, kind of, by recording a macro but it is a very ugly (Insert instead of xlup and loosing data validation...) way of doing it:
I know this can be done in an much more elegant way. Any help would be much appreciated.
On worksheet "Free IDs" I have Table1 from A1:J21 with headers, data validation and formulas.
On worksheet "MASTER LIST" I have Table2 with the same headers and no data atm (I removed all the historical data as it was a mess)
There is a button on the bottom of worksheet "FREE IDs" which needs to perform the following:
- copy data from Table1 (minus the header) to the end of Table2.
- clear data from Table1 from B2:J21 but keep data validation, formulas and set background to no fill color.
or
- clear data from Table1 keeping data validation, formulas, set background to no fill and repopulate column A (A2:A21) with sequential numbers carrying on from what was cleared. So the previous A21+1 would be the new A2...
I have managed to do this, kind of, by recording a macro but it is a very ugly (Insert instead of xlup and loosing data validation...) way of doing it:
VBA Code:
Sub CopyToMaster()
'
' CopyToMaster Macro
' copies the free ID table to the master table then resets the IDs.
Range("A2:J21").Select
Selection.Copy
Sheets("MASTER LIST").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Sheets("Free IDs").Select
Range("A21").Select
Application.CutCopyMode = False
Selection.Copy
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("A1:A21"), Type:=xlFillSeries
Range("A1:A21").Select
Range("A1").Select
ActiveCell.FormulaR1C1 = "ID"
Range("A1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Range("B2:J21").Select
Select
I know this can be done in an much more elegant way. Any help would be much appreciated.