Using Date Entered to Replace Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,665
Office Version
  1. 2019
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
 

Some videos you may like

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).

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
5,665
Office Version
  1. 2019
Platform
  1. Windows
Thanks for the help

Regards

Howard
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,665
Office Version
  1. 2019
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
 

Watch MrExcel Video

Forum statistics

Threads
1,114,384
Messages
5,547,638
Members
410,805
Latest member
Ginoji
Top