+ Reply to Thread
Results 1 to 4 of 4

Dim Shp As Shape, Dim Pic As Picture not wok

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-27-2021
    Location
    italy
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    109

    Dim Shp As Shape, Dim Pic As Picture not wok

    hi hello, I can not understand where I am wrong when I try to declare the variables excel gives me this error
    For Each Pic In .Pictures
    Option Explicit
    
    Sub AGGIORNADATI()
     
     Dim R As VbMsgBoxResult
     R = MsgBox(" Sei sicuro di volere aggiornare i dati?", vbYesNo + vbQuestion, "Aggiorna Dati")
     
     If R = vbYes Then
     
     'Aggiorna foto:
       Dim Shp As Shape
       Dim Pic As Picture
        With Sheets("ANALISI COMPOSIZIONE CORPOREA")
            For Each Shp In .Shapes
                If Shp.Type = msoPicture Then
                    Debug.Print Shp.Name, Shp.TopLeftCell
                    If Not Intersect(Shp.TopLeftCell, .Range("B19:O29,P19:AA29,AS8:AW18,AX8:BB18")) Is Nothing Then
                        Shp.Delete
                    End If
                End If
            Next
        End With
        With Sheets("ANALISI COMPOSIZIONE CORPOREA")
     For Each Pic In .Pictures
         If Not Intersect(Pic.TopLeftCell, .Range("BM8:BQ18,BR8:BV18")) Is Nothing Then
                Pic.Copy
                Pic.TopLeftCell.Offset(0, -20).Range("A1").PasteSpecial
            End If
        Next Pic
    End With
      With Sheets("ANALISI COMPOSIZIONE CORPOREA")
            For Each Shp In .Shapes
                If Shp.Type = msoPicture Then
                    Debug.Print Shp.Name, Shp.TopLeftCell
                    If Not Intersect(Shp.TopLeftCell, .Range("BM8:BQ18,BR8:BV18")) Is Nothing Then
                        Shp.Delete
                    End If
                End If
            Next
        End With
         
    
    'Aggiorna e resetta pilche:
      
      Range("BS24:BU24").Select
        ActiveCell.Offset(1, 0).Range("A1:C1").Select
        Selection.Copy
        ActiveCell.Offset(-1, 0).Range("A1:C1").Select
        Selection.End(xlDown).Select
        ActiveCell.Offset(1, 0).Range("A1:C1").Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
        ActiveCell.Offset(-2, 0).Range("A1:C1").Select
        Range( _
            "AT25:AU25,AT25:AU25,AT27:AU27,AT29:AU29,AT31:AU31,AT33:AU33,AT35:AU35,AT37:AU37,AW37:AX37,AW35:AX35,AW33:AX33,AW31:AX31,AW29:AX29,AW27:AX27,AW25:AX25,AZ25:BA25,AZ27:BA27,AZ29:BA29,AZ31:BA31,AZ33:BA33,AZ35:BA35,AZ37:BA37" _
            ).Select
        Range("AZ37").Activate
        Selection.ClearContents
        Range("BS24:BU24").Select
    
    
    'Copy and Paste a Range of Cells
    Range("D12:E12").Copy Range("BG7:BH7")
    Range("AF10:AG10").Copy Range("BG8:BG8")
    Range("AF11:AG11").Copy Range("BG9:BH9")
    Range("AF12:AG12").Copy Range("BG10:BH10")
    Range("AD13:AE13").Copy Range("BG11:BH11")
    Range("AF13:AG13").Copy Range("BG12:BH12")
    Range("AF14:AG14").Copy Range("BG13:BH13")
    Range("AF15:AG15").Copy Range("BG14:BH14")
    Range("AF16:AG16").Copy Range("BG15:BH15")
    Range("AF17:AG17").Copy Range("BG16:BH16")
    
    'Clear a Range of Cells
    Range("D12:E12").ClearContents
    Range("AF10:AG10").ClearContents
    Range("AF11:AG11").ClearContents
    Range("AF12:AG12").ClearContents
    Range("AD13:AE13").ClearContents
    Range("AF13:AG13").ClearContents
    Range("AF14:AG14").ClearContents
    Range("AF15:AG15").ClearContents
    Range("AF16:AG16").ClearContents
    
    'Clear a Range of Cells test
    Range("BY7:BZ7").Select
        Selection.ClearContents
           Range("BY20:BZ20").Select
        Selection.ClearContents
        Range("CC20").Select
        Selection.ClearContents
           Range("BY34:BZ34").Select
        Selection.ClearContents
        Range("CC34").Select
        Selection.ClearContents
            Range("BY59:BZ59").Select
        Selection.ClearContents
        Range("CC59").Select
        Selection.ClearContents
        Range("BZ63:CA63").Select
        Selection.ClearContents
    
    Range("D12:E12").Select
    
    MsgBox "Buon Lavoro!", vbInformation, "Dati Aggiornati"
    Else
       MsgBox "Come non detto!", vbInformation
      Exit Sub
      End If
    
    End Sub

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,343

    Re: Dim Shp As Shape, Dim Pic As Picture not wok

    What error are you getting?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    05-27-2021
    Location
    italy
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    109

    Re: Dim Shp As Shape, Dim Pic As Picture not wok

    For Each Pic In .Pictures
    Attached Images Attached Images

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,343

    Re: Dim Shp As Shape, Dim Pic As Picture not wok

    What error, not where?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 06-20-2016, 10:02 PM
  2. VBA code to set PICTURE shape attribute other than .name
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2015, 10:48 AM
  3. Changing a Picture's Shape
    By Shleifer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2014, 07:25 PM
  4. Changing a Picture's Shape
    By Shleifer in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-10-2014, 02:18 PM
  5. [SOLVED] deleting picture (shape)
    By TimlmiT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2014, 10:13 AM
  6. Adding Picture to Shape
    By ando185 in forum Excel General
    Replies: 0
    Last Post: 06-25-2013, 03:27 PM
  7. Shape/picture name in a worksheet
    By neta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-29-2006, 11:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1