Copy a Combobox and change the linked cell and listfillrange

BVOPP

Board Regular
Joined
Feb 9, 2015
Messages
57
I want to copy a template which contains a combo box from sheet "Change_Block" to the sheet "Scope_Changes" this will be one several times, so i don't know te combobox name upfront ..

I tried this in a macro .... but the " With Selection" gives the run time error 438: Object doesnt support this property or method

How to avoid this?


Code:
Sub Add_Change()

'determine the row to start the new change block
    Dim This_Sheet As String
    Dim lr, r As Long
    
    This_Sheet = "Scope_Changes"
    Worksheets(This_Sheet).Activate
    lr = Cells(Rows.Count, "I").End(xlUp).row
    
    r = lr + 3
    Sheets("Change_Block").Select
    Rows("1:19").Select
    Selection.Copy
    Sheets("Scope_Changes").Select
    Range("A" & r).Select
    ActiveSheet.Paste
    
    Sheets("Change_Block").Select
    ActiveSheet.Shapes.Range(Array("ComboBox1")).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Scope_Changes").Select
    Range("A" & r + 4).Select
    ActiveSheet.Paste
     With Selection
      .LinkedCell = "E" & r + 3
      .ListFillRange = Range("H" & r + 3).Value

    End With

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I want to copy a template which contains a combo box from sheet "Change_Block" to the sheet "Scope_Changes" this will be one several times, so i don't know te combobox name upfront ..

I tried this in a macro .... but the " With Selection" gives the run time error 438: Object doesnt support this property or method

How to avoid this?


Code:
Sub Add_Change()

'determine the row to start the new change block
    Dim This_Sheet As String
    Dim lr, r As Long
    
    This_Sheet = "Scope_Changes"
    Worksheets(This_Sheet).Activate
    lr = Cells(Rows.Count, "I").End(xlUp).row
    
    r = lr + 3
    Sheets("Change_Block").Select
    Rows("1:19").Select
    Selection.Copy
    Sheets("Scope_Changes").Select
    Range("A" & r).Select
    ActiveSheet.Paste
    
    Sheets("Change_Block").Select
    ActiveSheet.Shapes.Range(Array("ComboBox1")).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Scope_Changes").Select
    Range("A" & r + 4).Select
    ActiveSheet.Paste
     With Selection
      .LinkedCell = "E" & r + 3
      .ListFillRange = Range("H" & r + 3).Value

    End With

End Sub

I found it...if i change the name of the combobox then every next combobox will be named combobox1 and this is working fine then:
ActiveSheet.Paste
ActiveSheet.Shapes.Range(Array("ComboBox1")).Select
With Selection
.LinkedCell = "E" & r + 2
.ListFillRange = Range("H" & r + 2).Value
.Name = "Box" & r
End With
 
Upvote 0
That is odd.... yesterday it worked fine .. but now not anymore and i can't debug
when arrived at statement ActiveSheet.Shapes.Range(Array("ComboBox1")).Select
the debugger says: Can't enter break mode at this time.
Can some one help?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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