Match and Delete

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

Hey guys,

the below code does not work.
Dim FndRng As Range
Set FndRng = Worksheets(8).Range("J3:j100").Find
(ComboBox4.Value)
If Not FndRng Is Nothing Then
Range("J3").Resize(1, 10).Delete Shift:=xlShiftUp

I need it to do the following and cant get it to work.
On a userform I have Combobox4. On worksheets(8) Range
J3:J100 I have a range of values. Range K3:S100 is a
range of cooresponding values. The value in Combobox4
will match a value in range J3:J100. When it finds this
match in this range, I need for it to delete the values in
the matching row from column J to column S. I then need
for the code to pull all values below the deleted values up
to fill in the gap caused by the deletion.

For example I have data in range J3:S27. The value of
Combobox4 is "Dog" The value "Dog" is found in cell J23.
The code should then delete cells J23:S23 and then pull
the values in the remaining cells in columns J through S
of rows 24, 25, 26, and 27 up to fill in the gap when
cells J23:S23 were deleted.

I do not want to delete the entire row.
 
Dim FndRng As Range
Set FndRng = Worksheets(8).Range("J3:j100").Find
(ComboBox4.Value)
If Not FndRng Is Nothing Then
Range("J3").Resize(1, 10).Delete Shift:=xlShiftUp
Else
msgbox Combobox4.value & " was not found"
End if
 
Dim rngJ As Range
Set rngJ = Worksheets(8).Range("J3:J100").Find(Worksheets
(8).Range("T4"))
If Not rngJ Is Nothing Then
rngJ.Resize(, 10).Delete Shift:=xlShiftUp
End If

Above is the code I changed it to. This code works,
however it references a cell(cell T4) to find the lookup
value. I would like the lookup value to be a combobox
(combobox6.value). What would I modify the code to in
order to get it to do this?
 
Dim rngJ As Range
Set rngJ = Worksheets(8).Range("J3:J100").Find(Userform1.Combobox2.value)
If Not rngJ Is Nothing Then
rngJ.Resize(, 10).Delete Shift:=xlShiftUp
End If

could depend on what you are looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top