Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default User input into Macros in Excel 2000


Hi I am trying to add a "replace" function to a macro so that a part of an
equation in a worksheet can be changed. The syntax being used is
Cells.Replace What:="200907", Replacement:="200906", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
but I want the user to be able to change the 'What' and 'Replacement' values
via a dialogue box. Can anyone help please?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 257
Default User input into Macros in Excel 2000


I'm used to Excel 2003, but I imagine the InputBox function would work. You
could ask the user to enter the old and new values separated by a comma, or
you could do the InputBox twice, once for the old value and once for the new.
The InputBox function is built into VBA; you'll find it documented not in
the VBA/Excel help but in the Help for VBA itself.

I dunno as it's the smoothest way to do it, but it would at least work. If
you want to bring up a form with two textboxes in it, you'd have to resort to
VB Forms, which I think will work with Excel but I've never tried them yet so
I can't be much help with them.

Another possibility is just having the user enter the values in two cells
somewhere, before the macro starts, and your macro can just pull the values
from there. It might even be possible - I've never tried it - to stop the
macro, instructing the user to enter the values in two cells and THEN
resuming the program. But that might cause more trouble than it would save,
even if it could be done.

--- "RobJ" wrote:
Hi I am trying to add a "replace" function to a macro so that a part of an
equation in a worksheet can be changed. The syntax being used is
Cells.Replace What:="200907", Replacement:="200906", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
but I want the user to be able to change the 'What' and 'Replacement' values
via a dialogue box. Can anyone help please?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default User input into Macros in Excel 2000


Thanks Bob that worked a treat. I used 2 input boxes giving the names
'varname' and 'varname1' and the syntax below

varname = InputBox("Please blah blah below", _
"Change From", "200906.xls")
varname1 = InputBox("Please blah blah containing the NEW data in the
format shown below", _
"Change To", "200907.xls")

Cells.Replace What:=varname, Replacement:=varname1, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Don't know why I did not think of that my self.

Thanks again

"Bob Bridges" wrote:

I'm used to Excel 2003, but I imagine the InputBox function would work. You
could ask the user to enter the old and new values separated by a comma, or
you could do the InputBox twice, once for the old value and once for the new.
The InputBox function is built into VBA; you'll find it documented not in
the VBA/Excel help but in the Help for VBA itself.

I dunno as it's the smoothest way to do it, but it would at least work. If
you want to bring up a form with two textboxes in it, you'd have to resort to
VB Forms, which I think will work with Excel but I've never tried them yet so
I can't be much help with them.

Another possibility is just having the user enter the values in two cells
somewhere, before the macro starts, and your macro can just pull the values
from there. It might even be possible - I've never tried it - to stop the
macro, instructing the user to enter the values in two cells and THEN
resuming the program. But that might cause more trouble than it would save,
even if it could be done.

--- "RobJ" wrote:
Hi I am trying to add a "replace" function to a macro so that a part of an
equation in a worksheet can be changed. The syntax being used is
Cells.Replace What:="200907", Replacement:="200906", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
but I want the user to be able to change the 'What' and 'Replacement' values
via a dialogue box. Can anyone help please?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2000 User Forms & Macros - Will they work with Excel 2007 John[_134_] Excel Programming 2 November 24th 07 06:14 AM
input 7 in a cell in EXCEL 2000, it will automatically change to 8 nobattery Excel Discussion (Misc queries) 1 October 19th 06 01:25 PM
Excel Paste w/ No User Input Rich[_31_] Excel Programming 2 July 31st 06 09:14 AM
Have user input converted to uppercase in same cell as input? Shannonn New Users to Excel 1 June 20th 06 03:19 AM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 09:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"