View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob van Gelder[_4_] Rob van Gelder[_4_] is offline
external usenet poster
 
Posts: 1,236
Default Find and replace within VBA

Consider moving these dates into a lookup worksheet of it's own. The code
then references the lookup sheet whenever it needs the date.
Instead of:
If Date() = CDate("1-Mar-2004") Then
MsgBox "Greater than reference date"
End If

Use:
If Date = Worksheets("LookupData").Range("ReferenceDate").Va lue Then
MsgBox "Greater than reference date"
End If


If that's not an option, you could make the date a Public Const in it's own
module. That way you limit their exposure to the entire code.

eg.
In modConstants
Public Const cReferenceDate = "1-Mar-2004"

In modLoanCalcs
If Date() = CDate(cReferenceDate) Then
MsgBox "Greater than reference date"
End If



And last and most certainly least in this case, theres a find/replace code
example on my website.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"kateb " wrote in message
...
Hi,

I write macros that that extract data from my company's database. I
use the 'Edit-Replace' option in VB to change the dates that are
programmed to extract the data as they occur several times within the
macro.

Is it possible to program a userform (or similar) to do this?

For example I don't really want my clients playing directly with the
macro. I hoped I could have a userform pop-up that said 'Find' (they
insert the date) and 'Replace' (they insert the new date!) and upon
clicking OK the macro is changed and run!

I can only do this to use the 'Edit-Replace' option within Excel
rather than VBA

Any suggestions greatly recieved

Kate
Poole


---
Message posted from http://www.ExcelForum.com/