Functions of a Listbox without using a Listbox!?

LostCause

Board Regular
Joined
Jul 13, 2006
Messages
99
Firstly, thanks for reading.

I was previously using a listbox to do this but have been ordered not to use one!



What I would like to happen is, have a macro for each button that changes the value in cell C15, depending on which button was pressed (so Button 1 returns A, Button 2 returns B and Button 3 returns C.)

Just one example will do, I can adapt it to the other buttons!

Many thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi Lost!

Question:
Do you want "A" "B" & "C" respectively returned to C15, or the value of C6,7,and 8 respectively?
 
Upvote 0
You could do this in one macro, provided the buttons come from the Forms toolbar.

For example you could assign this macro to each button.
Code:
Sub Macro1()
    Range("C15") = Chr(Right(Application.Caller, 1) + Asc("A") - 1)
End Sub
Now this does exactly what you asked for, puts A, B or C in C15.

But I've a feeling you might actually want something a little different, for example pulling the values from C6:C9.

If that's the case try this.
Code:
Sub Macro1()
    Range("C15") = Range("C6").Offset(Right(Application.Caller, 1))
End Sub
 
Upvote 0
........yes, but do you want the LETTERS A B and C, or will the value of C6, 7 or 8 change, in which case you want the VALUES of C6,7 or 8 in C15?
 
Upvote 0
Thanks for your responses guys.

Maybe I oversimplified it a bit too much:

The letters in C6:C8 will vary depending on other things in the spreadsheet. Let's say they are product codes.

The purpose of the three buttons is to update cell C15 with the product code in question. I was then going to make the rest of the macro go to another sheet where the cell is referred and a lookup will be performed on it, to display information.

So Button 2 enters B in cell C15, and goes to another spreadsheet where more information about item B is displayed. I have no problem with the navigation to another sheet, it's the getting data into a specific cell part I'm struggling with.

I hope this made sense

Thanks!
 
Upvote 0
........yes, but do you want the LETTERS A B and C, or will the value of C6, 7 or 8 change, in which case you want the VALUES of C6,7 or 8 in C15?
Oh sorry, I should learn to read.

The values please

Thanks
 
Upvote 0
Did you try the code I posted?
 
Upvote 0
How did you try it?

How didn't it work?

PS what's the problem with using a Listbox?
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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