Best Practices When Coding Multiple Buttons Performing Similar Actions

JoshuaKC29

New Member
Joined
Apr 20, 2019
Messages
10
Wowza,

Wasn’t sure what was the best way to word my question. I’m currently working on a code that transfers dates from an excel sheet into a webform and selects a specific export button on the website (just pulling reports essentially).

Each button pulls a specific report. So there’s a need to specify the element ID of the from and to dates for each individual report as well as the ID of the button used to export the data.

Currently, I’ve assigned each button a macro that sets a Boolean to be True, then the macro calls the main subroutine. The main subroutine knows which text box to fill and which button to press based off of which Boolean is set to True.

i also have a requirement to have a button to execute an export of all reports. What I did to accomplish this was used an integer to determine if the export all button was selected. The initial macro sets the first Boolean to true and at the end of the main subroutine I check to see if the integer is = to 1, if so, the integer is = to the integer + 1, the initial Boolean is set to false, the next Boolean is set to true and I go to the start of the main subroutine until all reports have been pulled.

I only started learning VBA about 6 months ago so I’m sure a lot of my methods aren’t the most practical. I have a tendency to do what I know which is why I’m reaching out to see if there is possibly an angle I didn’t consider when working on this project.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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