#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Franky
 
Posts: n/a
Default workbook code

Hi,

I am confused as to how to call functions from a procedure. My
"ThisWorkbook" code creates new sheets and names them according to cells in a
list on "Original Data" sheet and ten applies a function that shows or hides
pictures depending on cell values. The problem is that the Function
ShowPictures doesn't work. That is, it works on its own if I have the code
in one individual sheet, but I can't seem to make it work on every sheet.
This code is in ThisWorkbook:
Private Sub TEMPLATE_COPY()

Dim cell As Range, Rng As Range
With Worksheets("Original Data")
Set Rng = .Range(.Range("A2:A1000"), .Range("A2:A1000").End(xlDown))
End With
For Each cell In Rng
If cell < "" Then
Sheets("BBB00161").Copy AFTER:=Sheets(Sheets.Count)
ActiveSheet.Name = cell.Value
ShowPictures ThisWorkbook.Worksheets(ActiveSheet)
End If
Next
End Sub

This code is in Module 1:
ub ShowPictures(sh As Worksheet)
sh.Activate
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("A6")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default workbook code

Sub ShowPictures(sh As Worksheet)
Dim oPic As Picture
sh.Pictures.Visible = False
With sh.Range("A6")
For Each oPic In sh.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Franky" wrote in message
...
Hi,

I am confused as to how to call functions from a procedure. My
"ThisWorkbook" code creates new sheets and names them according to cells

in a
list on "Original Data" sheet and ten applies a function that shows or

hides
pictures depending on cell values. The problem is that the Function
ShowPictures doesn't work. That is, it works on its own if I have the

code
in one individual sheet, but I can't seem to make it work on every sheet.
This code is in ThisWorkbook:
Private Sub TEMPLATE_COPY()

Dim cell As Range, Rng As Range
With Worksheets("Original Data")
Set Rng = .Range(.Range("A2:A1000"),

..Range("A2:A1000").End(xlDown))
End With
For Each cell In Rng
If cell < "" Then
Sheets("BBB00161").Copy AFTER:=Sheets(Sheets.Count)
ActiveSheet.Name = cell.Value
ShowPictures ThisWorkbook.Worksheets(ActiveSheet)
End If
Next
End Sub

This code is in Module 1:
ub ShowPictures(sh As Worksheet)
sh.Activate
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("A6")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub





  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Franky
 
Posts: n/a
Default workbook code

Thank you

"Bob Phillips" wrote:

Sub ShowPictures(sh As Worksheet)
Dim oPic As Picture
sh.Pictures.Visible = False
With sh.Range("A6")
For Each oPic In sh.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Franky" wrote in message
...
Hi,

I am confused as to how to call functions from a procedure. My
"ThisWorkbook" code creates new sheets and names them according to cells

in a
list on "Original Data" sheet and ten applies a function that shows or

hides
pictures depending on cell values. The problem is that the Function
ShowPictures doesn't work. That is, it works on its own if I have the

code
in one individual sheet, but I can't seem to make it work on every sheet.
This code is in ThisWorkbook:
Private Sub TEMPLATE_COPY()

Dim cell As Range, Rng As Range
With Worksheets("Original Data")
Set Rng = .Range(.Range("A2:A1000"),

..Range("A2:A1000").End(xlDown))
End With
For Each cell In Rng
If cell < "" Then
Sheets("BBB00161").Copy AFTER:=Sheets(Sheets.Count)
ActiveSheet.Name = cell.Value
ShowPictures ThisWorkbook.Worksheets(ActiveSheet)
End If
Next
End Sub

This code is in Module 1:
ub ShowPictures(sh As Worksheet)
sh.Activate
Dim oPic As Picture
Me.Pictures.Visible = False
With Range("A6")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic
End With
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
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 03:56 AM
Disable VBA code execution when loading a workbook Charles Excel Discussion (Misc queries) 4 October 14th 05 09:12 PM
Change case...help please Terry Excel Worksheet Functions 14 October 2nd 05 12:29 PM
VLOOKUP for Zip Code Ranges JerseyJR Excel Worksheet Functions 2 September 6th 05 06:37 PM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM


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