Macro For Inserting a Formula In Active Cell - Needs pop up to choose cell in Formula

uolymme637

New Member
Joined
Jul 17, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi all!
I am looking for help creating a macro that helps with the following:

I have a date field that comes out of my ERP that is in the following format MDDYYYY or MMDDYYYY (Depending on the month). Aka there is no leading zero for Jan-Sept.

I have solved this issue by creating the following formula, when the date is in C3
=IF(LEN(C3)=7,LEFT(C3,1)&"/"&MID(C3,2,2)&"/"&RIGHT(C3,4),LEFT(C3,2)&"/"&MID(C3,3,2)&"/"&RIGHT(C3,4)) - And then doing text to columns to get it formatted to a date

However I would like to create a macro that lets me put this formula in the active cell, but the date that I am using is not always in C3 (It is always in column C). Is there a way I can create a pop up, or tell it to use column C for the row it is currently in?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi & welcome to MrExcel.
You could use this simpler formula, which doesn't need text to columns
+Fluff New.xlsm
BCD
1
2113202013-Jan-20
3713202013-Jul-20
41113202013-Nov-20
Data
Cell Formulas
RangeFormula
D2:D4D2=DATE(RIGHT(C2,4),LEFT(C2,LEN(C2)-6),MID(C2,LEN(C2)-5,2))
 
Upvote 0
If my formula works for you, then try
VBA Code:
Sub uolymme()
   Selection.Offset(, 1).FormulaR1C1 = "=DATE(RIGHT(rc[-1],4),LEFT(rc[-1],LEN(rc[-1])-6),MID(rc[-1],LEN(rc[-1])-5,2))"
End Sub
Just select the cells in col C you want it to work on.
 
Upvote 0
Do you want it in a column?
 
Upvote 0
Nah I can always add column D and that will be best. Thank you again!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,342
Members
448,956
Latest member
Adamsxl

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