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.
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

bandit_1981

Board Regular
Joined
Aug 17, 2005
Messages
201
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.
 

vander

New Member
Joined
Dec 16, 2005
Messages
4
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?
 

bandit_1981

Board Regular
Joined
Aug 17, 2005
Messages
201
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,233
Messages
5,571,037
Members
412,357
Latest member
Djsi222
Top