Can you make a button Relative?

vander

New Member
Joined
Dec 16, 2005
Messages
4
I have a sheet with many of the same table. I want to export one table at a time, depending on which button i hit. Each button with be sitting next to its relative table.

Is there a way in VBA to select a range relative to the buttons location?

Thanks so much.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Why not just write a function that each button passes the info to. Then on each button place the range it is in.

sub Button_Click
call exporttable(position)
end sub

Then you only need to change one parameter on each button.
 
Upvote 0
i like your idea bandit_1981. i have some moderate java based programming experience, but am completely new to VBA. Do you mean to say i could just paste "call exporttable("A1:D4")" in to my existing macro code for the button and then the button will only effect that range?
 
Upvote 0
Ok first you will want to create a macro (aka) function that will export the table based upon the name of it.

Now you will want to create all of your buttons.

Now put this on the button clicks for each one

Button1_Click
call exporttable(TableName1)

Button2_Click
call exporttable(TableName2)


etc
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

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