If code help

Jazzer

Board Regular
Joined
Jun 14, 2011
Messages
71
Hello,

I am looking for some code to help wth the following please...

If B is not equal to H
Then I need to see if B matches H on the row below
if not does H match B on the row below

if H matches B on the row below then incert a row on H&I
if B matches H on the row below then incert a row on B&C

Does anybody understand?! and if so is this possible?

Many Thanks
James
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
you mean to say insert cells below the cells in columns H & I and same for B & C. Bcoz inserting rows for H or I will also insert it for B and C
 
Upvote 0
Are you using VBA to insert the rows (I assume so)?

Yes currently I have some code which I use to look up data from other tabs on my worksheet
Code:
 Sheets("LCHDATA").Select
    Range("C9").Select
    ActiveWindow.SmallScroll Down:=-9
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("REC").Select
    Range("B6").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Sheets("NOMADDATA").Select
    Range("K8").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("REC").Select
    Range("H6").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("B6").Select
    ActiveSheet.Range("$B$5:$C$200").RemoveDuplicates Columns:=1, Header:=xlYes
    Range("H6").Select
    ActiveSheet.Range("$H$5:$I$200").RemoveDuplicates Columns:=1, Header:=xlYes
    Range("C6").Select
    Selection.AutoFill Destination:=Range("C6:C200")
    Range("C6:C200").Select
    Range("I6").Select
    Selection.AutoFill Destination:=Range("I6:I200")
    Range("I6:I200").Select
    Range("A6").Select
End Sub

I just want to add to the existing code

thanks
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,633
Members
452,933
Latest member
patv

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