Using Macro Buttons to change the values of cells back and forth.

PuceSpade

New Member
Joined
Aug 7, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I would like to have a data set, with dates as column headers and unique codes as row headers, that can switch between different values. For example, Retail ($) and Tonnage. My first thought was to use Macros to populate a cell above the column headers that would be referenced in a VLOOKUP to designate a column to look in. However, that would only work if I had a Macro button for each date. Therefore, I tried to make the Macro button populate a cell with an HLOOKUP and that cell would be references in a VLOOKUP for the column index number. However, the equation would not work.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I would like to have a data set, with dates as column headers and unique codes as row headers, that can switch between different values. For example, Retail ($) and Tonnage.
No idea what that means but I'll take a stab at the problem anyway. If the date in a cell is the key, why not use the BeforeDoubleClick event? The value can be retrieved from the Target parameter of the event. To illustrate only that point perhaps try this:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

MsgBox Target
Cancel = True

End Sub
If that doesn't get you anywhere I think you'll have to explain better. Maybe post some sample data and desired results as pics or something else.
 
Upvote 0

Forum statistics

Threads
1,215,145
Messages
6,123,291
Members
449,094
Latest member
GoToLeep

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