Move up text

G

gregork

I have the following code for deleting an entry on a worksheet:

Dim rng As Range, res As Variant, rng1 As Range
Set rng = Worksheets("Blend Sheet").Range("b8:b23")


res = Application.Match(CStr(ComboBox1.Text), rng, 0)
If Not IsError(res) Then
Set rng1 = rng(res)
rng1.Offset(0, 5).Value = ClearContents
rng1.Offset(0, 0).Value = ClearContents


What do I need to add to the code to move up the entries in the cells below
the entry I am deleting and within the range ?

Greg
 
R

Rob van Gelder

Does your code work?
ClearContents is a method, but it looks like you've made a variable called
ClearContents.

The usual syntax is rng1.Offset(0, 5).ClearContents

To move the values from the row after, eg.
rng1.Offset(0, 5).Value = rng1.Offset(1, 5).Value


PS. What are you Blending?
 
B

Bob Phillips

Greg,

I think this is what you mean

Dim rng As Range, res As Variant, rng1 As Range
Set rng = Worksheets("Blend Sheet").Range("b8:b23")


res = Application.Match(CStr(ComboBox1.Text), rng, 0)
If Not IsError(res) Then
Set rng1 = rng(res)
rng1.Offset(0, 5).Delete Shift:=xlUp
rng1.Offset(0, 0).Delete Shift:=xlUp


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Similar Threads

Clear then move text up 9
Move Text Up 5
Match function and displaying results 3
delete row 2
Type Mismatch Error 5
Double_byte find problem 1
compare all matches 3
Multiple Match 2

Top