PDA

View Full Version : VBA Check Cells - Easy but help!



pundabuyer
08-07-2008, 02:57 PM
:banghead: Hi Guys this will probs be simple for you but i cant figure it out,

I have 6 Columns for this script,

I have columns D E U V W X

I have about 200 rows for each..

i want to write some code that takes the top cell in Column V ("V16" as there are titles and gaps etc) and check it against every none blank cell in column D (From D16 down) if there is a match I want U16 copying to E16 and then U16 and V16 deleting and the cells shifting up. the process then starts again.

If excel cant find a match from V16 in Column D I want U16 and V16 Cutting and pasting in W16 and X16 respectively and then U16 and V16 shifting up and the proccess starts again... the reason for this is that i want to know which ones we have no match for... I currently have this code but it doesnt work as i am an amateur! Thanks Guys I Appreciate it

Dim a As Integer
Dim z As Integer
Dim As Integer
w = 16
a = 16
z = 16

1:
Do


If Range("V" & z).Value = Range("D" & a).Value Then
Range("E" & a).Value = Range("U" & z).Value
a = 16
Range("u16:v16").Delete Shift:=xlUp
Else

a = a + 1
If a > 312 Then
Range("U16:V16").Select
Selection.Cut
Range("W" & w, "X" & w).Select
ActiveSheet.Paste
Range("u16:v16").Delete Shift:=xlUp
w = w + 1
a = 16
GoTo 1

End If
Loop Until Range("U16").Value = ""