View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GLT GLT is offline
external usenet poster
 
Posts: 12
Default Updating varibales in a worksheet

Hi Norman,

Thanks for your response - your solution works great except my example I
gave was a simplified example. In my case, I'm actually dealing with several
different sets of weeks (ie. set 1 is 'week 1 to 4', set 2 is 'week 1 to 12',
set 3 is 'week 1 to 16').

If I use the find and replace, trying to update the set 1 week only will
update all of the other sets as well.

Unfortuantely I am stuck with them all having the same names as they are
tied to systems that we use at work.

I tried using the following in a cell:

='2) Print updates for Week('& weekNo &')'

But it did not work either....

Thanks,
GLT

"Norman Jones" wrote:

Hi GLT,

Try something like:

'=============
Public Sub Tester001()
Dim weekNo As Long

weekNo = InputBox("Enter week number")

Columns("A:A").Replace _
What:="week(?)", _
Replacement:="Week(" & weekNo & ")", _
LookAt:=xlPart, _
SearchOrder:=xlByRows

Columns("A:A").Replace _
What:="week(??)", _
Replacement:="Week(" & weekNo & ")", _
LookAt:=xlPart, _
SearchOrder:=xlByRows
End Sub
'<<=============

---
Regards,
Norman



"GLT" wrote in message
...
I have a list of items that are done on a four week basis.
When my spreadsheet opens, it asks the user which week the items is for
(1,
2, 3 or 4) via a INPUTBOX.

Within each cell on the worksheet, there is a list of tasks which look
similar to the following example:

1) Update MAFGHI for Week( )
2) Print updates for Week( )

I would like to automatically insert the varible from the macro into Week(
), so that it automatically updates it to Week(4) without having to type
it
manually through the document.

The above example would look like this, after the user has input which
weeek:

1) Update MAFGHI for Week(4)
2) Print updates for Week(4)


I understand how to set a cell value from a variable, but how do I update
just one character from a variable within a cell that contains mutiple
characters?

Thanks,
GLT