Vba Delete range of cells in a row based on value in another cell from combo box

Heath1974

New Member
Joined
Oct 25, 2013
Messages
5
Hi I'm hoping someone can help with this I thought it would be simple but my grasp on vba is very limited, I found the below code online and it works however it deletes the entire row I need to delete from column B:DA based on a number from a cell that I retrieve from a combo box (Drop down form control). It is also requiring the source value which I get from the combo box to be in more than one cell as this code was originally for deleting rows based on multiple values I would prefer just the one with a cell reference would be even better and easier for me to wrap my tiny brain around.

Sub Button4_Click
'
' Button4_Click Macro
'

'
Dim deleteRows As Range
Dim SourceWks As Worksheet, deleteWks As Worksheet

Set SourceWks = Sheet 6
Set deleteWks = Sheet 1

With SourceWks
data = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
End With

Set deleteRows = deleteWks.Rows(data(1, 1))

For i = 2 To Ubound(data, 1)
Set deleteRows = Union(deleteRows, deleteWks.Row(data(I, 1)))

Next i

deleteRows.Delete Shift:=xlUp

End Sub


Thanks to anyone in advance

Heath
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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