PDA

View Full Version : VBA Query



dawoodmpm
01-22-2019, 11:50 PM
Hi Friends,

Hope you are doing good.

I am beginner of this forum and vba codes.i am preparing small worksheet for my small grocery. I just wanted to know when i click the macro command button in the attached worksheet in "PAYMENT' , Name shown in command button has to appear the PAYMENT table which is blank (Start from the empty cells in Items(to be appear in Yellow highlighted cells).
To make more clear, While clicking command button "PEN","PENCIL","ERASOR" it should be appear in payment table "ITEM-1","Item-2","ITEM-3" likewise start from top cell which is blank.(I have more than 100 items)

So Kindly help me.

大灰狼1976
01-30-2019, 12:18 AM
Hi dawoodmpm!

Sub Button3_Click()
Dim DCC As Long
Dim ABC As Worksheet
Set ABC = Sheets("PAYMENT")
DCC = Sheets("PAYMENT").Range("C" & Rows.Count).End(xlUp).Column
With ABC
.Cells(DCC + 5, 3).Value = .Buttons("Button 3").Text
End With
End Sub

大灰狼1976
01-30-2019, 12:56 AM
sorry

Sub Button3_Click()
Dim DCC As Long
Dim ABC As Worksheet
Set ABC = Sheets("PAYMENT")
DCC = Sheets("PAYMENT").Range("C" & Rows.Count).End(xlUp).Row
With ABC
.Cells(DCC + 1, 3).Value = .Buttons("Button 3").Text
End With
End Sub

大灰狼1976
01-30-2019, 12:58 AM
There is data in 25 row and more than 40000 row, must be deleted first.

dawoodmpm
01-30-2019, 04:14 AM
Thanks Mr.大灰狼1976 (http://www.vbaexpress.com/forum/member.php?70849-大灰狼1976)

It is really great and work well.But when i press t command button,it is pasting on the same cell instead of first blank cell.so please advise how to make the text to be appear in the first blank cell whatever the command button pressed

Thanks

Dawood.

大灰狼1976
01-30-2019, 06:24 PM
Hi dawoodmpm!
Please refer to the attachment.

dawoodmpm
01-31-2019, 01:37 AM
Thank you Mr.大灰狼1976 (http://www.vbaexpress.com/forum/member.php?70849-大灰狼1976) http://www.vbaexpress.com/forum/images/statusicon/user-online.png

It really works well.Once again i really thank you for your help.

大灰狼1976
01-31-2019, 02:00 AM
that's alright!
Please mark it as resolved.:yes