Hi,
I've made a code to copy data from a loader table and move it to the data, but it keeps on coming up with the same error. Was wondering if anybody could fix the error because I have tried but can't see, to fix it. The bug occurs at the text in red. But if there are any other bugs would be good to have those fixed too.
Thanks
The code is:
Dim DataRow, LoadColumns, LoadRows, UpdateRow, ReplaceRow, StartRow, EndRow, VisRow As Integer
Sub LoadUpdate()
'
' LoadUpdate Macro
' Pastes new data from Loader into DataTable at bottom of table
Application.ScreenUpdating = False
' Get row number in DataTable where table starts
Application.Goto Reference:="StartData"
StartRow = ActiveCell.Row
' Get row number in DataTable where new data will be pasted
Application.Goto Reference:="LastRow"
EndRow = ActiveCell.Value
DataRow = EndRow - StartRow + 1
' Get size of datablock for newly entered data in Loader
Application.Goto Reference:="NewRows"
LoadRows = ActiveCell.Value - 1
Application.Goto Reference:="NewColumn"
LoadColumns = ActiveCell.Value - 1
' Add extra rows to DataTable so that Named Ranges are auto updated
AddRows
' Select new data in Loader and copy
Application.Goto Reference:="StartLoad"
Range(ActiveCell, ActiveCell.Offset(LoadRows, LoadColumns)).Select
Selection.Copy
' Paste new data to DataTable
DataLoad
'****ClearNew macro disabled so that the Loader table can be seperately reset****
' ClearNew
Application.Goto Reference:="StartData"
' Flag that data has been transferred to DataTable
Sheets("ReptSelect").Visible = True
Application.Goto Reference:="LoadDone"
Selection.Copy
Application.Goto Reference:="LoadCheck"
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.Goto Reference:="LoadDone"
ActiveWindow.SelectedSheets.Visible = False
Application.Goto Reference:="StartLoad"
Application.CutCopyMode = False
End Sub
Sub AddRows()
' Macro subroutine used by LoadUpdate macro
'
' Extends the DataTable by adding the number of new rows to be pasted from Loader
' Required to ensure named ranges are extended beyond the new data
Application.Goto Reference:="StartData"
ActiveCell.Offset(DataRow + 2, 0).Select
Range(ActiveCell, ActiveCell.Offset(LoadRows, 300)).Select
' *** Note - extends rows out to column 300 (ie Column KN),
' if more columns are added need to change in preceding row in macro***
Selection.Insert Shift:=xlDown
End Sub
Sub DataLoad()
' Macro subroutine used by LoadUpdate macro
'
' Position in cell and paste new data into Prod_Data table
Application.Goto Reference:="StartData"
ActiveCell.Offset(DataRow, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
' Application.Goto Reference:="StartData"
End Sub
Sub AddCalcs()
'
' Macro subroutine used by LoadUpdate macro
'
' Update the formulae that are to the right of added data in the DataTable
Application.Goto Reference:="DataFormulae"
Selection.Copy
ActiveCell.Offset(DataRow - 1, 0).Select
Range(ActiveCell, ActiveCell.Offset(LoadRows, 0)).Select
ActiveSheet.Paste
End Sub
Sub ClearNew()
' Reset the Loader input table to blank form for new data entry
' Requires a blank but preformatted copy of the input table stored below the used sheet
Application.Goto Reference:="NewSet"
Selection.Copy
Application.Goto Reference:="StartLoad"
' ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
' Flag that data has not been transferred to DataTable
Sheets("ReptSelect").Visible = True
Application.Goto Reference:="LoadToDo"
Selection.Copy
Application.Goto Reference:="LoadCheck"
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.Goto Reference:="LoadDone"
ActiveWindow.SelectedSheets.Visible = False
Application.CutCopyMode = False
Application.Goto Reference:="StartLoad"
ActiveWindow.SmallScroll Down:=-1
End Sub
I've made a code to copy data from a loader table and move it to the data, but it keeps on coming up with the same error. Was wondering if anybody could fix the error because I have tried but can't see, to fix it. The bug occurs at the text in red. But if there are any other bugs would be good to have those fixed too.
Thanks
The code is:
Dim DataRow, LoadColumns, LoadRows, UpdateRow, ReplaceRow, StartRow, EndRow, VisRow As Integer
Sub LoadUpdate()
'
' LoadUpdate Macro
' Pastes new data from Loader into DataTable at bottom of table
Application.ScreenUpdating = False
' Get row number in DataTable where table starts
Application.Goto Reference:="StartData"
StartRow = ActiveCell.Row
' Get row number in DataTable where new data will be pasted
Application.Goto Reference:="LastRow"
EndRow = ActiveCell.Value
DataRow = EndRow - StartRow + 1
' Get size of datablock for newly entered data in Loader
Application.Goto Reference:="NewRows"
LoadRows = ActiveCell.Value - 1
Application.Goto Reference:="NewColumn"
LoadColumns = ActiveCell.Value - 1
' Add extra rows to DataTable so that Named Ranges are auto updated
AddRows
' Select new data in Loader and copy
Application.Goto Reference:="StartLoad"
Range(ActiveCell, ActiveCell.Offset(LoadRows, LoadColumns)).Select
Selection.Copy
' Paste new data to DataTable
DataLoad
'****ClearNew macro disabled so that the Loader table can be seperately reset****
' ClearNew
Application.Goto Reference:="StartData"
' Flag that data has been transferred to DataTable
Sheets("ReptSelect").Visible = True
Application.Goto Reference:="LoadDone"
Selection.Copy
Application.Goto Reference:="LoadCheck"
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.Goto Reference:="LoadDone"
ActiveWindow.SelectedSheets.Visible = False
Application.Goto Reference:="StartLoad"
Application.CutCopyMode = False
End Sub
Sub AddRows()
' Macro subroutine used by LoadUpdate macro
'
' Extends the DataTable by adding the number of new rows to be pasted from Loader
' Required to ensure named ranges are extended beyond the new data
Application.Goto Reference:="StartData"
ActiveCell.Offset(DataRow + 2, 0).Select
Range(ActiveCell, ActiveCell.Offset(LoadRows, 300)).Select
' *** Note - extends rows out to column 300 (ie Column KN),
' if more columns are added need to change in preceding row in macro***
Selection.Insert Shift:=xlDown
End Sub
Sub DataLoad()
' Macro subroutine used by LoadUpdate macro
'
' Position in cell and paste new data into Prod_Data table
Application.Goto Reference:="StartData"
ActiveCell.Offset(DataRow, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
' Application.Goto Reference:="StartData"
End Sub
Sub AddCalcs()
'
' Macro subroutine used by LoadUpdate macro
'
' Update the formulae that are to the right of added data in the DataTable
Application.Goto Reference:="DataFormulae"
Selection.Copy
ActiveCell.Offset(DataRow - 1, 0).Select
Range(ActiveCell, ActiveCell.Offset(LoadRows, 0)).Select
ActiveSheet.Paste
End Sub
Sub ClearNew()
' Reset the Loader input table to blank form for new data entry
' Requires a blank but preformatted copy of the input table stored below the used sheet
Application.Goto Reference:="NewSet"
Selection.Copy
Application.Goto Reference:="StartLoad"
' ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
' Flag that data has not been transferred to DataTable
Sheets("ReptSelect").Visible = True
Application.Goto Reference:="LoadToDo"
Selection.Copy
Application.Goto Reference:="LoadCheck"
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.Goto Reference:="LoadDone"
ActiveWindow.SelectedSheets.Visible = False
Application.CutCopyMode = False
Application.Goto Reference:="StartLoad"
ActiveWindow.SmallScroll Down:=-1
End Sub