Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Copying Variables in VB Editor In Excel

Hi

Am not hot on VB and am stuck. Have recorded a macro
which uses text written into a box, running the macro to
run a mass replace job over 10 sheets. When I do this,
everything works apart from the macro always replaces
what was originally in the box rather than whatever is
typed. How do I change this constant into a variable
copy/paste? Please keep it simple if you can help!!!

Thank you for any help you can give

Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Copying Variables in VB Editor In Excel

Tony,

Paste the code for us to see.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tony" wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a macro
which uses text written into a box, running the macro to
run a mass replace job over 10 sheets. When I do this,
everything works apart from the macro always replaces
what was originally in the box rather than whatever is
typed. How do I change this constant into a variable
copy/paste? Please keep it simple if you can help!!!

Thank you for any help you can give

Tony



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Copying Variables in VB Editor In Excel

As asked. This is a small part of what I want to do, as
this needs to be replicated for 30 different names.

Thanks

Tony

Sub Replace()
'
' Macro10 Macro
' Macro recorded 02/11/2003 by TB
'

'
Range("A2").Select
ActiveCell.FormulaR1C1 = "Trish"
Range("G3").Select
Sheets("Week 1").Select
Cells.Replace What:="Blank1", Replacement:="Trish",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True
Sheets("Week 2").Select
Cells.Replace What:="Blank1", Replacement:="Trish",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True
Sheets("Week 3").Select
Cells.Replace What:="Blank1", Replacement:="Trish",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True
Sheets("Week 4").Select
Cells.Replace What:="Blank1", Replacement:="Trish",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True
Sheets("Name").Select
End Sub

-----Original Message-----
Tony,

Paste the code for us to see.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tony" wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a macro
which uses text written into a box, running the macro

to
run a mass replace job over 10 sheets. When I do this,
everything works apart from the macro always replaces
what was originally in the box rather than whatever is
typed. How do I change this constant into a variable
copy/paste? Please keep it simple if you can help!!!

Thank you for any help you can give

Tony



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying Variables in VB Editor In Excel


Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("enter item to be replaced")
sStr1 = InputBox("enter replacement")
Application.displayalerts = False
For Each sh In Worksheets(Array("sheet1", "sheet2", . . . , _
"sheet9","sheet10"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Next
Application.displayalerts = True
End Sub

replace ... with the list of additional sheet names.

--
Regards,
Tom Ogilvy


Tony wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a macro
which uses text written into a box, running the macro to
run a mass replace job over 10 sheets. When I do this,
everything works apart from the macro always replaces
what was originally in the box rather than whatever is
typed. How do I change this constant into a variable
copy/paste? Please keep it simple if you can help!!!

Thank you for any help you can give

Tony



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Copying Variables in VB Editor In Excel

This is what I have done, obviously wrong, can you show
me forward again please?

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("L2")
sStr1 = InputBox("A2")
Application.DisplayAlerts = False
(Array(("Week1", "Week2", "Week3", Week4"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False
Next
Application.DisplayAlerts = True
End Sub



-----Original Message-----

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("enter item to be replaced")
sStr1 = InputBox("enter replacement")
Application.displayalerts = False
For Each sh In Worksheets(Array

("sheet1", "sheet2", . . . , _
"sheet9","sheet10"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,

MatchCase:=False
Next
Application.displayalerts = True
End Sub

replace ... with the list of additional sheet names.

--
Regards,
Tom Ogilvy


Tony wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a macro
which uses text written into a box, running the macro

to
run a mass replace job over 10 sheets. When I do this,
everything works apart from the macro always replaces
what was originally in the box rather than whatever is
typed. How do I change this constant into a variable
copy/paste? Please keep it simple if you can help!!!

Thank you for any help you can give

Tony



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying Variables in VB Editor In Excel

Sub ReplaceItems()
Dim sh As Worksheet
Dim sStr As String
Dim sStr1 As String
' assume your values are in L2 and A2 of the active sheet
sStr Range("L2").Value
sStr1 = Range("A2").Value
Application.DisplayAlerts = False
For Each sh In Worksheets(Array("Week1", _
"Week2", "Week3", "Week4"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False
Next
Application.DisplayAlerts = True
End Sub

--
Regards,
Tom Ogilvy

Tony wrote in message
...
This is what I have done, obviously wrong, can you show
me forward again please?

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("L2")
sStr1 = InputBox("A2")
Application.DisplayAlerts = False
(Array(("Week1", "Week2", "Week3", Week4"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False
Next
Application.DisplayAlerts = True
End Sub



-----Original Message-----

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("enter item to be replaced")
sStr1 = InputBox("enter replacement")
Application.displayalerts = False
For Each sh In Worksheets(Array

("sheet1", "sheet2", . . . , _
"sheet9","sheet10"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,

MatchCase:=False
Next
Application.displayalerts = True
End Sub

replace ... with the list of additional sheet names.

--
Regards,
Tom Ogilvy


Tony wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a macro
which uses text written into a box, running the macro

to
run a mass replace job over 10 sheets. When I do this,
everything works apart from the macro always replaces
what was originally in the box rather than whatever is
typed. How do I change this constant into a variable
copy/paste? Please keep it simple if you can help!!!

Thank you for any help you can give

Tony



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Copying Variables in VB Editor In Excel

Coming up with box saying

Complile Error
Expected Sub, Function or Property

in reference to line
sStr Range("L2").Value

when I debug

please advise
-----Original Message-----
Sub ReplaceItems()
Dim sh As Worksheet
Dim sStr As String
Dim sStr1 As String
' assume your values are in L2 and A2 of the active sheet
sStr Range("L2").Value
sStr1 = Range("A2").Value
Application.DisplayAlerts = False
For Each sh In Worksheets(Array("Week1", _
"Week2", "Week3", "Week4"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False
Next
Application.DisplayAlerts = True
End Sub

--
Regards,
Tom Ogilvy

Tony wrote in message
...
This is what I have done, obviously wrong, can you show
me forward again please?

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("L2")
sStr1 = InputBox("A2")
Application.DisplayAlerts = False
(Array(("Week1", "Week2", "Week3", Week4"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False
Next
Application.DisplayAlerts = True
End Sub



-----Original Message-----

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("enter item to be replaced")
sStr1 = InputBox("enter replacement")
Application.displayalerts = False
For Each sh In Worksheets(Array

("sheet1", "sheet2", . . . , _
"sheet9","sheet10"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,

MatchCase:=False
Next
Application.displayalerts = True
End Sub

replace ... with the list of additional sheet names.

--
Regards,
Tom Ogilvy


Tony wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a

macro
which uses text written into a box, running the

macro
to
run a mass replace job over 10 sheets. When I do

this,
everything works apart from the macro always

replaces
what was originally in the box rather than whatever

is
typed. How do I change this constant into a

variable
copy/paste? Please keep it simple if you can

help!!!

Thank you for any help you can give

Tony


.



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying Variables in VB Editor In Excel

sStr = Range("L2").Value


Tony wrote in message
...
Coming up with box saying

Complile Error
Expected Sub, Function or Property

in reference to line
sStr Range("L2").Value

when I debug

please advise
-----Original Message-----
Sub ReplaceItems()
Dim sh As Worksheet
Dim sStr As String
Dim sStr1 As String
' assume your values are in L2 and A2 of the active sheet
sStr Range("L2").Value
sStr1 = Range("A2").Value
Application.DisplayAlerts = False
For Each sh In Worksheets(Array("Week1", _
"Week2", "Week3", "Week4"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False
Next
Application.DisplayAlerts = True
End Sub

--
Regards,
Tom Ogilvy

Tony wrote in message
...
This is what I have done, obviously wrong, can you show
me forward again please?

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("L2")
sStr1 = InputBox("A2")
Application.DisplayAlerts = False
(Array(("Week1", "Week2", "Week3", Week4"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False
Next
Application.DisplayAlerts = True
End Sub



-----Original Message-----

Sub ReplaceItems()
Dim sh As Worksheet
Dim str As String
sStr = InputBox("enter item to be replaced")
sStr1 = InputBox("enter replacement")
Application.displayalerts = False
For Each sh In Worksheets(Array
("sheet1", "sheet2", . . . , _
"sheet9","sheet10"))
sh.Cells.Replace What:=sStr, Replacement:=sStr1, _
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False
Next
Application.displayalerts = True
End Sub

replace ... with the list of additional sheet names.

--
Regards,
Tom Ogilvy


Tony wrote in message
...
Hi

Am not hot on VB and am stuck. Have recorded a

macro
which uses text written into a box, running the

macro
to
run a mass replace job over 10 sheets. When I do

this,
everything works apart from the macro always

replaces
what was originally in the box rather than whatever

is
typed. How do I change this constant into a

variable
copy/paste? Please keep it simple if you can

help!!!

Thank you for any help you can give

Tony


.



.



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
Equation Editor & Excel Jess Excel Worksheet Functions 2 September 2nd 09 08:27 PM
Copying functions without changing most variables in it Ruleroftheblind Excel Discussion (Misc queries) 3 March 12th 09 04:54 AM
How do I get Equation Editor on the Toolbar in Excel? Excel_Eqn_Ed Setting up and Configuration of Excel 1 February 14th 07 05:44 PM
Excel 2007 : Equation editor rogerlebo Excel Discussion (Misc queries) 0 June 6th 06 10:23 PM
Libraries In Excel VB Editor ccdubs Excel Programming 1 July 28th 03 12:31 AM


All times are GMT +1. The time now is 03:33 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"