Help with VB Code, posting, counting, and clearing data

Raustin

Board Regular
Joined
Mar 21, 2011
Messages
50
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:
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
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top