Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Please help with code

In workbook "planning ticket.xls" cell E8 there is following formula: ='C:\Documents and Settings\Tickets\[8250.xls]Prod.Ticket'!A16
(it looks up value of cell A16 in workbook 8250.xls)

In the event that cell F1 is changed to a new value e.g.: 7722, I'd like to have the formula in E8 changed to: ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A16

Is this possible, somehow?
Norbert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Please help with code

Hi Norbert,

Am Mon, 27 Aug 2012 07:37:59 -0700 (PDT) schrieb Norbert:

In workbook "planning ticket.xls" cell E8 there is following formula: ='C:\Documents and Settings\Tickets\[8250.xls]Prod.Ticket'!A16
(it looks up value of cell A16 in workbook 8250.xls)

In the event that cell F1 is changed to a new value e.g.: 7722, I'd like to have the formula in E8 changed to: ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A16


try in code module of the worksheet:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPath As String
Dim wbName As String

If Target.Address < "$F$1" Then Exit Sub
myPath = "'C:\Documents and Settings\Tickets\"
wbName = "[" & [F1] & ".xls]Prod.Ticket'!A16"
Range("E8").Formula = "=" & myPath & wbName

End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Please help with code

On Monday, August 27, 2012 6:14:34 PM UTC+2, Claus Busch wrote:
Hi Norbert,



Am Mon, 27 Aug 2012 07:37:59 -0700 (PDT) schrieb Norbert:



In workbook "planning ticket.xls" cell E8 there is following formula: ='C:\Documents and Settings\Tickets\[8250.xls]Prod.Ticket'!A16


(it looks up value of cell A16 in workbook 8250.xls)




In the event that cell F1 is changed to a new value e.g.: 7722, I'd like to have the formula in E8 changed to: ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A16




try in code module of the worksheet:



Private Sub Worksheet_Change(ByVal Target As Range)

Dim myPath As String

Dim wbName As String



If Target.Address < "$F$1" Then Exit Sub

myPath = "'C:\Documents and Settings\Tickets\"

wbName = "[" & [F1] & ".xls]Prod.Ticket'!A16"

Range("E8").Formula = "=" & myPath & wbName



End Sub





Regards

Claus Busch

--

Win XP PRof SP2 / Vista Ultimate SP2

Office 2003 SP2 /2007 Ultimate SP2


Hi Claus,
your code works fine, thank you for that.
What I did not mention, there are plenty other cells like E8, with the same path in the formula but obviously linking to a different cell.

For example:
E8 ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A16
AL7 ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!BT7
AP7 ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A60
and more ...

How can I include those into the code?
As far as I can read your code, string wbName is different all the time, but
I have no knowledge of how to change it.

Regards,
Norbert
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Please help with code

On Tuesday, August 28, 2012 9:18:39 AM UTC+2, Norbert wrote:
On Monday, August 27, 2012 6:14:34 PM UTC+2, Claus Busch wrote:

Hi Norbert,








Am Mon, 27 Aug 2012 07:37:59 -0700 (PDT) schrieb Norbert:








In workbook "planning ticket.xls" cell E8 there is following formula: ='C:\Documents and Settings\Tickets\[8250.xls]Prod.Ticket'!A16




(it looks up value of cell A16 in workbook 8250.xls)








In the event that cell F1 is changed to a new value e.g.: 7722, I'd like to have the formula in E8 changed to: ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A16








try in code module of the worksheet:








Private Sub Worksheet_Change(ByVal Target As Range)




Dim myPath As String




Dim wbName As String








If Target.Address < "$F$1" Then Exit Sub




myPath = "'C:\Documents and Settings\Tickets\"




wbName = "[" & [F1] & ".xls]Prod.Ticket'!A16"




Range("E8").Formula = "=" & myPath & wbName








End Sub












Regards




Claus Busch




--




Win XP PRof SP2 / Vista Ultimate SP2




Office 2003 SP2 /2007 Ultimate SP2




Hi Claus,

your code works fine, thank you for that.

What I did not mention, there are plenty other cells like E8, with the same path in the formula but obviously linking to a different cell.



For example:

E8 ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A16

AL7 ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!BT7

AP7 ='C:\Documents and Settings\Tickets\[7722.xls]Prod.Ticket'!A60

and more ...



How can I include those into the code?

As far as I can read your code, string wbName is different all the time, but

I have no knowledge of how to change it.



Regards,

Norbert


Hi Claus,
I found a way, which is most likely the most awkward one but it works:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPath As String
'Dim wbName As String

If Target.Address < "$F$1" Then Exit Sub
myPath = "'C:\Documents and Settings\Muhammad\My Documents\PRODUCTION SPECS\"
wbName = "[" & [F1] & ".xls]"
Range("W7").Formula = "=" & myPath & wbName & "Prod.Ticket'!BT7"
Range("AL7").Formula = "=" & myPath & wbName & "Prod.Ticket'!A60"
Range("AP7").Formula = "=" & myPath & wbName & "Prod.Ticket'!A66"
Range("E8").Formula = "=" & myPath & wbName & "Prod.Ticket'!A16"
...
...
...
End sub
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
Creating excel file, adding code to it from code, VBE window stays BlueWolverine Excel Programming 0 November 5th 09 07:55 PM
How can I modify my code to offset the defined range and repeat theprocedure instead of duplicating my code? [email protected] Excel Programming 4 May 29th 09 10:13 PM
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Excel Programming 6 October 3rd 08 09:45 PM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


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