VBA - Run Two loops and Confirm Range doesn't include loopping Value

JJCA99

Board Regular
Joined
Dec 4, 2014
Messages
50
Hi Guys,

I have the code below but for some reason I'm missing making an error on my code.

So in Range AM8:BE8 I have headers that will always change/update.
In Column BR contains values that I want to add into my range AM8:BE8 but only if it doesn't exist yet.

For some reason the headers keep double up on me.
here is the code I have.
Thanks.

Code:
 aps = Cells(Rows.Count, 70).End(xlUp).Row
 dt = 1
 
    
       
With SPsum ' this is the sheet I'm working on
   For p = 1 To aps
    
    APT = Cells(p, 70)
If Range("$AM$8:$BE$8") <> p Then
 AT = SPsum.Range("BF8").End(xlToLeft).Column + 1
 SPsum.Cells(8, AT) = APT
End If
Next p

 
End With
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Code:
Sub a()
    Dim c As Variant, fnd As Range, ColumnHead As Range, HeaderList As Range
    Set ColumnHead = Range(Cells(8, 39), Cells(8, 58).End(xlToLeft))
    Set HeaderList = Range("BR1:BR" & Cells(Rows.Count, "BR").End(xlUp).Row)
    For Each c In HeaderList
        Set fnd = ColumnHead.Find(c, , , xlWhole)
        If fnd Is Nothing Then Cells(8, 58).End(xlToLeft).Offset(, 1) = c
    Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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