Using Date Entered to Replace Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,135
Office Version
  1. 2021
Platform
  1. Windows
I have a worksheet F & I Comm, that links data from another spreadsheet.

I need VBA code to be written that will do the following:

1) Prompt the user to enter a date for EG Sept2006 which will be entered into cell E1

2) The date that was enter in cell E1 must be used to relace the word template in all cells in the worksheet "F & I Comm" that contains the word Template ( The full name of one of the linked files is ='[MONTH END.New Vehicles.Template.xls]STATS'!$G$15). I only need the word template replaced in each cell where this appears.

Your assistance will be most appreciated

Howard
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

gaj104

Well-known Member
Joined
Nov 9, 2002
Messages
864
Something like this should do the trick

Code:
Sub ChangeTemp()

Dim tDate As String

tDate = InputBox("Enter Date", "DD/MM/YYYY")

    If IsDate(tDate) = False Then
    MsgBox ("Value entered is not valid!")
    Exit Sub
    End If

tDate = Format(tDate, "MMMYYYY")
Range("E1").Value = tDate

Cells.Replace What:="MONTH END.New Vehicles.Template.xls", Replacement:="MONTH END.New Vehicles." & tDate & ".xls", LookAt:=xlPart

End Sub
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,135
Office Version
  1. 2021
Platform
  1. Windows
Thanks for the help

Regards

Howard
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,135
Office Version
  1. 2021
Platform
  1. Windows
Finding and Replacing Name

Hi Graeme

Thanks for your help regarding setting up VBA code. The code needs to be fine tuned, so I took the liberty of attaching the workfile as well as the file the file that needs to be updated with the words Sept2006.

Your assistance will be most appreciated.

Kind regards

Howard
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,128
Messages
5,857,531
Members
431,884
Latest member
Gcmoore63

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
Top