Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to change formulae on worksheet?


Hi all i'm trying to create some code that will change all the formulae
on a certain sheet because i am using the Indirect function i dont want
to have to change 3000 formulae manually so i was hoping i could get
this right......but i am having trouble.....Any ideas?

Regards,
Simon

Sub frmlaChng()
Dim mycell
Dim rng As Range
Dim r
Set rng = Range("PriceForm")
With Sheets("summary sheet")
r = "F" & mycell.Row.Number
For Each mycell In rng
mycell.Text = "=VLOOKUP(INDIRECT(" & r & "),EventList,2,FALSE)"
Next mycell
End With
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=563936

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to change formulae on worksheet?


It is very hard to tell. Can you post a sample spreadsheet so we can see
what you are trying to do

Matt


--
Mallycat
------------------------------------------------------------------------
Mallycat's Profile: http://www.excelforum.com/member.php...o&userid=35514
View this thread: http://www.excelforum.com/showthread...hreadid=563936

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to change formulae on worksheet?


Matt all i am trying to do is save me a lot of manual work by running
the code above, once run it should put this =VLOOKUP(INDIRECT(" F2
"),EventList,2,FALSE) in each cell in my named range except it will
read =VLOOKUP(INDIRECT(" F3 "),EventList,2,FALSE) on row 3 and "F4" on
row 4 thats why i tried to use =VLOOKUP(INDIRECT(" & r &
"),EventList,2,FALSE) where r would be exchanged for F and the row
number, it really doesnt matter what spreadsheet its working with as i
am trying to populate each cell in the named range using the code.

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=563936

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Code to change formulae on worksheet?


Hi Simon

Try the following which l have slightly modified



Sub frmlaChng()
Dim mycell
Dim rng As Range
Dim r
Set rng = Range("PriceForm")
With Sheets("summary sheet")
For Each mycell In rng
r = "F" & mycell.Row
mycell.Formula = "=VLOOKUP(INDIRECT(" & r &
"),EventList,2,FALSE)"
Next mycell
End With
End Sub





Regards

Michael Beckinsale

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to change formulae on worksheet?


Hi Micheal, thanks for the reply and mods..........i
worked!..........well so far as it put the required formula in all th
cells i wanted, the only trouble is all the formula have this loo
=VLOOKUP(INDIRECT(F1),eventlist,2,FALSE) which gives #Ref! but th
formula needs to look like thi
=VLOOKUP(INDIRECT("F1"),eventlist,2,FALSE), it's just the inverte
commas that are missing i tried adding double quotes but this gave a
error.......do you know how to fixx this?

Regards,
Simo

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=56393



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Code to change formulae on worksheet?


Hi simon,

Sorry for not replying sooner but l have not visited the newsgroup
until now.

Try this

mycell.Formula = "=VLOOKUP(INDIRECT(" & Chr(34) & r & Chr(34) &
"),EventList,2,FALSE)"

let me know how it goes

Regards

Michael

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
change the name of a worksheet/update VBA code Dave F[_2_] Excel Discussion (Misc queries) 1 June 8th 07 09:22 PM
Code Conflicts With Worksheet Change Code Paige Excel Programming 3 March 3rd 06 04:25 PM
Code to run on worksheet selection change dan winterton Excel Programming 3 December 17th 04 11:45 PM
Code not working after worksheet change. Erik Excel Programming 0 September 17th 04 04:01 AM
Worksheet change code Frank Kabel Excel Programming 1 July 27th 04 04:58 PM


All times are GMT +1. The time now is 11:51 PM.

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"