Hello,
I am working on a project, and i need a bit of help with the code which will all take place on button click.. I currently have this as my code:
I actually need 4 things to happen on the click of a button:
1. When the button is clicked on Sheet1, i need the values in specific cells, say A5, B10, and C15 to be copied over to the first available row in a table in sheet2. (As of now the above code only functions when the selected box is in the row to be copied) I would like to have the specific cells copied over from sheet1 ever time, regardless of where the current cell focus is.
2. I would like a set of cells, Say D5:D15 from Sheet1 cleared of their values when the same button is pressed.
3. I have a cell in Sheet1 with a numerical value (say E4) I would like to have this value increase by 1, each time the button is clicked.
4. I would also like a pop-up message letting the user know "Values have been copied" (As of now we have a pop-up when the limit of rows is reached, which is fine as well)
Thanks again for all your help and support, as i am a newbie with VB code.
Randy
I am working on a project, and i need a bit of help with the code which will all take place on button click.. I currently have this as my code:
Code:
Private Sub CommandButton1_Click()
Dim lst As Long
Dim CurrRw As Long
lst = Sheet5.Range("a" & Rows.Count).End(xlUp).Row + 1
CurrRw = ActiveCell.Row
If ActiveSheet.Name <> "Invoice" Then Exit Sub
If lst >= 20 Then 'alter to be the last row of table
MsgBox "Table Limit Reached!!, data will not be copied"
Exit Sub
End If
Cells(CurrRw, 1).Resize(1, 3).Copy Sheet5.Cells(lst, 1) 'copy columns A-c of ActiveRow to next available in Sheet2
End Sub
I actually need 4 things to happen on the click of a button:
1. When the button is clicked on Sheet1, i need the values in specific cells, say A5, B10, and C15 to be copied over to the first available row in a table in sheet2. (As of now the above code only functions when the selected box is in the row to be copied) I would like to have the specific cells copied over from sheet1 ever time, regardless of where the current cell focus is.
2. I would like a set of cells, Say D5:D15 from Sheet1 cleared of their values when the same button is pressed.
3. I have a cell in Sheet1 with a numerical value (say E4) I would like to have this value increase by 1, each time the button is clicked.
4. I would also like a pop-up message letting the user know "Values have been copied" (As of now we have a pop-up when the limit of rows is reached, which is fine as well)
Thanks again for all your help and support, as i am a newbie with VB code.
Randy