CiaranEire
New Member
- Joined
- Dec 4, 2013
- Messages
- 9
Hi,
I am setting up an excel file to use as a database (MSAccess currently not an option) with a data entry sheet and a table sheet. The data entry sheet is set up to use 8 columns per day times 365 days (data is entered in columns B to DHQ). I have set it up like this as it is the currently the method best suited to my needs (Vs. using a VBA form).
What I am seeking help with is linking the table sheet to the data entry sheet. I have pasted the links for the first data column (B) and transposed for them to be in table format. Now I need a macro to copy the first row and paste down, incrementally increasing the column by 1 each time. So, B becomes C, C becomes D etc.
Here is my sample code:
What I know about VBA has been learned through trial and error and adapting code found on forums so all help is greatly appreciated. I will gladly clarify if any of the above isn't clear or if not as it should be according to forum best practices.
Ciaran
I am setting up an excel file to use as a database (MSAccess currently not an option) with a data entry sheet and a table sheet. The data entry sheet is set up to use 8 columns per day times 365 days (data is entered in columns B to DHQ). I have set it up like this as it is the currently the method best suited to my needs (Vs. using a VBA form).
What I am seeking help with is linking the table sheet to the data entry sheet. I have pasted the links for the first data column (B) and transposed for them to be in table format. Now I need a macro to copy the first row and paste down, incrementally increasing the column by 1 each time. So, B becomes C, C becomes D etc.
Here is my sample code:
Code:
Sub CopyTableDown()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim replacecol As String
Dim x As Integer
replacecol = 2 'or B
Application.CutCopyMode = False
Sheet2.Range("A2:CB2").Copy
For x = 1 To 7 'or to 2928 for B to DHQ
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Selection.Replace What:=replacecol, Replacement:=[COLOR=#ff0000][B]replacecol + 1[/B][/COLOR], LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
replacecol = [COLOR=#ff0000][B]replacecol + 1[/B][/COLOR]
Next x
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
What I know about VBA has been learned through trial and error and adapting code found on forums so all help is greatly appreciated. I will gladly clarify if any of the above isn't clear or if not as it should be according to forum best practices.
Ciaran