Using Date Entered to Replace Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,974
Messages
6,122,536
Members
449,088
Latest member
RandomExceller01

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