Excel VBA Programming, button linked to a row
Solved
PANTPUFLE
-
PANTPUFLE Posted messages 10 Status Membre -
PANTPUFLE Posted messages 10 Status Membre -
Hello,
I have been looking for a solution to my problem on different forums without success. I created an Excel document to schedule various orders and their delivery dates. I added a "Schedule" button in front of each line to delete the row where it is located. However, the button is programmed with the cell number, which means that if I add a row in the meantime, the button will not be in front of the correct line.
I hope I'm being clear, but basically, I need to delete columns C to G but only on the line of the button. I’m not sure if this is possible.
Thank you in advance for your response.
Configuration: Windows / Firefox 80.0
I have been looking for a solution to my problem on different forums without success. I created an Excel document to schedule various orders and their delivery dates. I added a "Schedule" button in front of each line to delete the row where it is located. However, the button is programmed with the cell number, which means that if I add a row in the meantime, the button will not be in front of the correct line.
I hope I'm being clear, but basically, I need to delete columns C to G but only on the line of the button. I’m not sure if this is possible.
Thank you in advance for your response.
Configuration: Windows / Firefox 80.0
3 réponses
yg_be
Posted messages
23437
Registration date
Status
Contributeur
Last intervention
Ambassadeur
1 588
Hello, I don’t understand the connection between your first and second paragraphs.
I wonder if it's a good idea to have a button on each line.
Can you share your file?
I wonder if it's a good idea to have a button on each line.
Can you share your file?
PANTPUFLE
Posted messages
10
Status
Membre
Hello, I replied to your message below :)
Hello, I'm aware that I'm not being very clear in my statements, so I'll try to clarify.
First of all, I'm providing you with the link to the Excel file because I couldn't integrate it in any other way:
https://www.cjoint.com/c/JIxinC7lWYa
On my order sheet, we can see for the client SNCF (which is an example) that there are different orders, different dates, etc. In front of each line, there is a button associated with the line. When my order is delivered, it would be more convenient for me to delete my data from the table in the cells from C to G. My problem is the following. If I have an additional order one day, I would need to add a line to this table, thus changing the cell numbers. The button not remaining in its assigned cell, the VBA code would then be incorrect as it would delete the data from another cell.
I would therefore like to either be able to link my button to a cell, regardless of line addition or deletion, so that the buttons remain on the correct cell number assigned to them. Or to know if it is possible to program the button so that it deletes the data from its cell without having to specify the numbers in Range("C32:G32").
Thank you very much for your response.
First of all, I'm providing you with the link to the Excel file because I couldn't integrate it in any other way:
https://www.cjoint.com/c/JIxinC7lWYa
On my order sheet, we can see for the client SNCF (which is an example) that there are different orders, different dates, etc. In front of each line, there is a button associated with the line. When my order is delivered, it would be more convenient for me to delete my data from the table in the cells from C to G. My problem is the following. If I have an additional order one day, I would need to add a line to this table, thus changing the cell numbers. The button not remaining in its assigned cell, the VBA code would then be incorrect as it would delete the data from another cell.
I would therefore like to either be able to link my button to a cell, regardless of line addition or deletion, so that the buttons remain on the correct cell number assigned to them. Or to know if it is possible to program the button so that it deletes the data from its cell without having to specify the numbers in Range("C32:G32").
Thank you very much for your response.
yg_be
Posted messages
23437
Registration date
Status
Contributeur
Last intervention
Ambassadeur
1 588
another method would be to use a single macro and associate all the buttons with this macro.
you can even copy the button across all rows.
Sub button() ActiveSheet.Buttons(Application.Caller).TopLeftCell.Offset(0, 2).Resize(1, 5).ClearContents End Sub
you can even copy the button across all rows.
This method should be used if you are assigning a macro to the buttons (the same macro to all buttons).
https://support.microsoft.com/en-us/office/assign-a-macro-to-a-form-or-a-control-button-d58edd7d-cb04-4964-bead-9c72c843a283
https://support.microsoft.com/en-us/office/assign-a-macro-to-a-form-or-a-control-button-d58edd7d-cb04-4964-bead-9c72c843a283