Need help with button macros PLS I'M GOING INSANE!

CallmeKay

New Member
Joined
Dec 31, 2022
Messages
2
Platform
  1. Windows
Hii, I am really at a loss right now q.q
I'm super new to Excel and (in this case) Google Sheets so I don't have any clue about macros and how to program them.

Here's my problem:
I want to add a command button that, when clicked, adds a calue to the cell BELOW it. Thing is, I can't for the life of me figure out how to tell Sheets that I want to have the BUTTON as a reference for the action and NOT the active cell!

I've tried using range commands but... eeeeh like I said, no idea, don't speak the language, tutorials are useless online.
If someone could help me figure this out that'd be wonderful, please I'm going insane over here I just want this to work T-T

Love, Kay
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Can you work with this?
VBA Code:
Private Sub CommandButton1_Click()
Dim R As Long, C As Long 'values for row and column position of top left of button

With Sheets("6").Shapes("CommandButton1").TopLeftCell
     R = .Row
     C = .Column
End With

Cells(R + 2, C) = "TEST"

End Sub
You'd have to use your own sheet and commandbutton names.
+2 depends on the height of your button. I don't think there is a bottom left property for a commandbutton but I didn't look.
 
Upvote 0
Can you work with this?
VBA Code:
Private Sub CommandButton1_Click()
Dim R As Long, C As Long 'values for row and column position of top left of button

With Sheets("6").Shapes("CommandButton1").TopLeftCell
     R = .Row
     C = .Column
End With

Cells(R + 2, C) = "TEST"

End Sub
You'd have to use your own sheet and commandbutton names.
+2 depends on the height of your button. I don't think there is a bottom left property for a commandbutton but I didn't look.
Unfortunately not, Google Sheets doesn't support VBA, only Google Apps Script which is based on Java :c
 
Upvote 0
I didn't glean from your post that "sheets" meant Google sheets when you started out with mentioning Excel. Oh well, I guess I learned something at least.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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