Code running query???

Molden

Active Member
Joined
Jun 20, 2006
Messages
373
Hi,

Does anyone no why code just starts running when it shouldnt. I wanted to delete a row on one of my sheets but when I did the combo on that sheet ran its code which resulted in an a vb error? The code on my combobox is:

Private Sub ComboBox1_Click()


Dim vRange
Dim LastCell As Long

Sheet1.Rows("11:65536").Delete

Sheet3.Select

'Range("M3:P3").AutoFilter 4, Me.ComboBox1

vRange = Array("A3", "D3", "H3")

For i = LBound(vRange) To UBound(vRange)
Sheet3.Range(vRange(i)).Select

Do
ActiveCell.Offset(1, 0).Select
Loop While ActiveCell.EntireRow.Hidden = True

Sheet3.Range(ActiveCell, Sheet3.Cells(65536, ActiveCell.Column).End(xlUp)).Select
Selection.Copy

Select Case i

Case 0

Sheet1.Range("B11").PasteSpecial xlPasteValues

Case 1

Sheet1.Range("C11").PasteSpecial xlPasteValues

End Select

Next i


End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Is your combobox bound to the worksheet using ListFillRange or LinkedCell properties? That would cause it.
 
Upvote 0
Yeah it was list fill range. Changed it to the for and next function and now works perfectly.

Life saver, many thanks

Michael
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

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