#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Macro Error

I have a macro that seems to be unfinished. I want a macro to activate when
a cell = "Yes". The macro will open the my pictures folder for someone to
insert a pic. I modified the macro so the picture will fit in the cells and
be resized. I have two of these macros on the same row but in different
columns. When I run the macro with the frist cell it works fine. The second
one however will place the picture in the first cell that I started with and
open the my picture document a second time. Here is the code:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
ws_exit:
Application.EnableEvents = True

End Sub


Can someone assist me with this problem?

Thank you,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Macro Error

SORRY HERE IS THE CODE:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Me.Range("$B$186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("$A$183:$D$191").Height
Selection.Width = Range("$A$183:$D$191").Width
Selection.Top = Range("$A$183:$D$191").Top
Selection.Left = Range("$A$183:$D$191").Left
Selection.Placement = xlMoveAndSize

End If

If Me.Range("$G$186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("$F$183:$I$191").Height
Selection.Width = Range("$F$183:$I$191").Width
Selection.Top = Range("$F$183:$I$191").Top
Selection.Left = Range("$F$183:$I$191").Left
Selection.Placement = xlMoveAndSize

End If
ws_exit:
Application.EnableEvents = True

"Daniel R. Young" wrote:

I have a macro that seems to be unfinished. I want a macro to activate when
a cell = "Yes". The macro will open the my pictures folder for someone to
insert a pic. I modified the macro so the picture will fit in the cells and
be resized. I have two of these macros on the same row but in different
columns. When I run the macro with the frist cell it works fine. The second
one however will place the picture in the first cell that I started with and
open the my picture document a second time. Here is the code:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
ws_exit:
Application.EnableEvents = True

End Sub


Can someone assist me with this problem?

Thank you,

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Error

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Target.Address = "$B$186" Then
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
ElseIf Target.Address = "$B$194" then
if me.Range("B194").Value = "Yes" then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A192:D200").Height
Selection.Width = Range("A192:D200").Width
Selection.Top = Range("A192:D200").Top
Selection.Left = Range("A192:D200").Left
Selection.Placement = xlMoveAndSize
End if
End If
ws_exit:
Application.EnableEvents = True

End Sub

--
Regards,
Tom Ogilvy

"Daniel R. Young" wrote in message
...
I have a macro that seems to be unfinished. I want a macro to activate

when
a cell = "Yes". The macro will open the my pictures folder for someone to
insert a pic. I modified the macro so the picture will fit in the cells

and
be resized. I have two of these macros on the same row but in different
columns. When I run the macro with the frist cell it works fine. The

second
one however will place the picture in the first cell that I started with

and
open the my picture document a second time. Here is the code:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
ws_exit:
Application.EnableEvents = True

End Sub


Can someone assist me with this problem?

Thank you,



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Error

Just adapt my guess to match your specifics.

--
Regards,
Tom Ogilvy

"Daniel R. Young" wrote in message
...
SORRY HERE IS THE CODE:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Me.Range("$B$186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("$A$183:$D$191").Height
Selection.Width = Range("$A$183:$D$191").Width
Selection.Top = Range("$A$183:$D$191").Top
Selection.Left = Range("$A$183:$D$191").Left
Selection.Placement = xlMoveAndSize

End If

If Me.Range("$G$186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("$F$183:$I$191").Height
Selection.Width = Range("$F$183:$I$191").Width
Selection.Top = Range("$F$183:$I$191").Top
Selection.Left = Range("$F$183:$I$191").Left
Selection.Placement = xlMoveAndSize

End If
ws_exit:
Application.EnableEvents = True

"Daniel R. Young" wrote:

I have a macro that seems to be unfinished. I want a macro to activate

when
a cell = "Yes". The macro will open the my pictures folder for someone

to
insert a pic. I modified the macro so the picture will fit in the cells

and
be resized. I have two of these macros on the same row but in different
columns. When I run the macro with the frist cell it works fine. The

second
one however will place the picture in the first cell that I started with

and
open the my picture document a second time. Here is the code:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
ws_exit:
Application.EnableEvents = True

End Sub


Can someone assist me with this problem?

Thank you,



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Macro Error

THANKS TOM!!!
I got it with this:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Target.Address = "$B$186" Then
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
End If
If Target.Address = "$G$186" Then
If Me.Range("G186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("F183:I191").Height
Selection.Width = Range("F183:I191").Width
Selection.Top = Range("F183:I191").Top
Selection.Left = Range("F183:I191").Left
Selection.Placement = xlMoveAndSize
End If
End If
ws_exit:
Application.EnableEvents = True

End Sub

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Target.Address = "$B$186" Then
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
ElseIf Target.Address = "$B$194" then
if me.Range("B194").Value = "Yes" then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A192:D200").Height
Selection.Width = Range("A192:D200").Width
Selection.Top = Range("A192:D200").Top
Selection.Left = Range("A192:D200").Left
Selection.Placement = xlMoveAndSize
End if
End If
ws_exit:
Application.EnableEvents = True

End Sub

--
Regards,
Tom Ogilvy

"Daniel R. Young" wrote in message
...
I have a macro that seems to be unfinished. I want a macro to activate

when
a cell = "Yes". The macro will open the my pictures folder for someone to
insert a pic. I modified the macro so the picture will fit in the cells

and
be resized. I have two of these macros on the same row but in different
columns. When I run the macro with the frist cell it works fine. The

second
one however will place the picture in the first cell that I started with

and
open the my picture document a second time. Here is the code:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = True
If Me.Range("B186").Value = "Yes" Then
Application.Dialogs(xlDialogInsertPicture).Show
Selection.Height = Range("A183:D191").Height
Selection.Width = Range("A183:D191").Width
Selection.Top = Range("A183:D191").Top
Selection.Left = Range("A183:D191").Left
Selection.Placement = xlMoveAndSize
End If
ws_exit:
Application.EnableEvents = True

End Sub


Can someone assist me with this problem?

Thank you,




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
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
naming tab macro error runtime error 1004 D Excel Programming 3 February 28th 05 01:32 AM
Macro 'Automation error' with ChemOffice Excel macro Stew Excel Programming 0 October 27th 03 08:26 PM


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