Macro to utilize drop-down

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hi everyone, I have a macro which edits and populates a template (which has other macros in it) and I need to populate a drop-down value for the month. The value is a numerical value of the current month, so I entered a code which would go to the cell "A15" and populate with the numerical value of the current month (10).

However, after populating it, the form doesn't work. Is there a macro which can select the drop-down and use the values in there as opposed to hard coding that cell?

Thanks : )
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
There should be no difference populating the cell directly via the code or via the drop-down. A possible cause of the problem could be that the code is entering the text "10" whereas the drop-down has a numeric 10, or vice-versa. Could that be the problem?
 
Upvote 0
Solution
There should be no difference populating the cell directly via the code or via the drop-down. A possible cause of the problem could be that the code is entering the text "10" whereas the drop-down has a numeric 10, or vice-versa. Could that be the problem?
Thanks for that. you are right. The number value i entered was a date format, so "10" was actually 44096 due to the date format.

VBA Code:
With Range("C4")
.NumberFormat = "@"
.Value = Format(DateAdd("m", -1, Date), "m")
.NumberFormat = "General"
End With

this is what helped me. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,740
Messages
6,180,678
Members
452,993
Latest member
FDARYABEE

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