Help with Code

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
I moved the referenced table on the sheet from cell A3 to B3 (moved it over one column). Now this code does not work. I though I adjusted it correctly but apparently I did not. Nothing happens - no errors either

Code:
Sub SelectProposal()

'*Clear Table: Selected_Proposal

    With Worksheets("Selected Proposal").ListObjects("Selected_Proposal")
    .Range.AutoFilter
    On Error Resume Next
    .DataBodyRange.Offset(1).Resize(.DataBodyRange.Rows.Count - 1, .DataBodyRange.Columns.Count).Rows.Delete
    
        If .ListColumns.Count > 1 Then
            .DataBodyRange.Rows(1).SpecialCells(xlCellTypeConstants).ClearContents
        Else
    
            With .DataBodyRange.Cells(1)
        If Not .HasFormula Then .ClearContents
        End With
    
        End If
    
    End With
    
'*Move the Selected Proposal Data to the Selected Proposal Table

    Dim sh As Worksheet
    Dim tblPropList As ListObject
    Dim lastRow As ListRow
    Dim SCR As Variant
    Dim fnd As Variant
    Dim Lr As Long
    
    Set sh = Sheet1
    Set tblPropList = sh.ListObjects("Proposal_List")

    Lr = Cells(Rows.Count, "B").End(xlUp).Row

If Intersect(ActiveCell, Range("B3:M" & Lr)) Is Nothing Then
    MsgBox "You must select a cell within the applicable Proposal Row.  Select a valid Cell"
    Exit Sub
End If


Sheets("Proposal Selection").Range("B" & ActiveCell.Row & ":" & "M" & ActiveCell.Row).Copy
Sheets("Selected Proposal").Range("A2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    Application.CutCopyMode = False

UserFormSP.Show

End Sub
What did I miss?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
It appears its an ActiveX issue. I put a Text Box on my sheet. Once I removed the TextBox the code worked again.
 
Upvote 0
As you discovered, ActiveX controls are finicky. They have the ability to "look pretty" with the varying properties but ... they can sometimes kill a project.
I found out first hand a few weeks ago and had to manually re-code the entire project. No small feat.

Best to stay away from ActiveX
 
Upvote 0
Solution

Forum statistics

Threads
1,215,011
Messages
6,122,680
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top