Hi all
I'm wondering if I could ask for any help. I have a simple workbook where one of the sheets (named Master) has a designed form where the cells have drop down menu inputs. I have written a vba code so that when a "Submit" button is pressed on the "Master" sheet it copies this inputted data to a sheet called "DATABASE" (in the same workbook). The vba code then clears the "Master" sheet and saves it. The vba pastes the contents on the "DATASHEET" across columns, so in an order.
At present there are several separate cells and then a block of cells that I would like to copy the data from. If I have the vba code copy from just the block ("B6:I16") for example it works, copies the data and then clears the content from the "Master" form. If I add another "single cell" reference, for example ("C2, B6:I16") it reports an error "Run-time error '1004': This action won't work on multiple selections". The code I've written is.....
Id really appreciate any help with this
Trevor
Sub copy()
Sheets("Master").Range("B6:I16").copy
Sheets("DATASHEET").Select
Dim LastRow As Long
LastRow = Sheets("DATASHEET").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
ActiveSheet.Range("A1").Cells(LastRow, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Worksheets("Master").Range("C2,F2,C6:I16").ClearContents
ActiveWorkbook.Save
Sheets("Master").Select
End Sub
I'm wondering if I could ask for any help. I have a simple workbook where one of the sheets (named Master) has a designed form where the cells have drop down menu inputs. I have written a vba code so that when a "Submit" button is pressed on the "Master" sheet it copies this inputted data to a sheet called "DATABASE" (in the same workbook). The vba code then clears the "Master" sheet and saves it. The vba pastes the contents on the "DATASHEET" across columns, so in an order.
At present there are several separate cells and then a block of cells that I would like to copy the data from. If I have the vba code copy from just the block ("B6:I16") for example it works, copies the data and then clears the content from the "Master" form. If I add another "single cell" reference, for example ("C2, B6:I16") it reports an error "Run-time error '1004': This action won't work on multiple selections". The code I've written is.....
Id really appreciate any help with this
Trevor
VBA Code:
Sheets("Master").Range("B6:I16").copy
Sheets("DATASHEET").Select
Dim LastRow As Long
LastRow = Sheets("DATASHEET").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
ActiveSheet.Range("A1").Cells(LastRow, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Worksheets("Master").Range("C2,F2,C6:I16").ClearContents
ActiveWorkbook.Save
Sheets("Master").Select
End Sub
VBA Code:
Last edited: