Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Update formula in Multi sheets

Excel 2003
I have the spreadsheet that has 50 sheets. I now want to add a formula to
the same cell in each sheet.
The procedure I have is as follows but it doesn't work - it doesn't add the
formula to the cell:

Any ideas?

Sub UpdateDesc()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect
Rows("5:5").RowHeight = 18.75
Range("G5").Select
ActiveCell.Formula =
"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," ",VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE))"
wks.EnableSelection = xlUnlockedCells
wks.Protect
End If
Next

End Sub

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Update formula in Multi sheets

Hi Newbie,

Sub UpdateDesc()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect
Rows("5:5").RowHeight = 18.75
Range("G5").Select
ActiveCell.Formula =

"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," ",VLOOKUP(B4,Contract
s!$A$1:$E$168,5,FALSE))"
wks.EnableSelection = xlUnlockedCells
wks.Protect
End If
Next

End Sub


Your code references the active worksheet, precede every range object
with the worksheet object:

Sub UpdateDesc()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect
wks.Rows("5:5").RowHeight = 18.75
wks.Range("G5").Formula =
"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," ",VLOOKUP(B4,Contract
s!$A$1:$E$168,5,FALSE))"
wks.EnableSelection = xlUnlockedCells
wks.Protect
End If
Next

End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Update formula in Multi sheets

Thanks but this still doesn't work. It changes the row height but doesn't
add the formula

Any other ideas?

"Jan Karel Pieterse" wrote in message
...
Hi Newbie,

Sub UpdateDesc()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect
Rows("5:5").RowHeight = 18.75
Range("G5").Select
ActiveCell.Formula =

"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," ",VLOOKUP(B4,Contract
s!$A$1:$E$168,5,FALSE))"
wks.EnableSelection = xlUnlockedCells
wks.Protect
End If
Next

End Sub


Your code references the active worksheet, precede every range object
with the worksheet object:

Sub UpdateDesc()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect
wks.Rows("5:5").RowHeight = 18.75
wks.Range("G5").Formula =
"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," ",VLOOKUP(B4,Contract
s!$A$1:$E$168,5,FALSE))"
wks.EnableSelection = xlUnlockedCells
wks.Protect
End If
Next

End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Update formula in Multi sheets

I've fixed it . for some reason it needed """" (2 pairs of double quotes)
to give a blank cell if nothing found

"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," """,VLOOKUP(B4,Contract
s!$A$1:$E$168,5,FALSE))"



"Newbie" wrote in message
...
Thanks but this still doesn't work. It changes the row height but doesn't
add the formula

Any other ideas?

"Jan Karel Pieterse" wrote in message
...
Hi Newbie,

Sub UpdateDesc()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect
Rows("5:5").RowHeight = 18.75
Range("G5").Select
ActiveCell.Formula =

"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," ",VLOOKUP(B4,Contract
s!$A$1:$E$168,5,FALSE))"
wks.EnableSelection = xlUnlockedCells
wks.Protect
End If
Next

End Sub


Your code references the active worksheet, precede every range object
with the worksheet object:

Sub UpdateDesc()
Dim wks As Worksheet
On Error Resume Next
For Each wks In ActiveWorkbook.Worksheets
wks.Unprotect
wks.Rows("5:5").RowHeight = 18.75
wks.Range("G5").Formula =
"=IF(VLOOKUP(B4,Contracts!$A$1:$E$168,5,FALSE)=0," ",VLOOKUP(B4,Contract
s!$A$1:$E$168,5,FALSE))"
wks.EnableSelection = xlUnlockedCells
wks.Protect
End If
Next

End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com







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
update vlookup formula sheet reference for multiple sheets SRH@Boise Excel Worksheet Functions 5 May 8th 10 08:51 AM
How to update data from multiple sheets to one specific sheets Khawajaanwar Excel Discussion (Misc queries) 4 January 15th 10 07:31 AM
Auto-update with multi-users Stephane Bisson Excel Worksheet Functions 1 June 18th 05 01:18 PM
Do..Loop in multi sheets norika Excel Programming 7 May 26th 05 07:44 AM
Sum Array Formula Across Multi Sheets SMS - John Howard Excel Programming 2 January 17th 05 01:37 PM


All times are GMT +1. The time now is 05:26 PM.

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

About Us

"It's about Microsoft Excel"