Hello all thanks for taking a look.
I am running a masking macro that uses data on a sheet (Sheets1) where column A has the User ID, ex. A1: A) 123456789, and then an offset 2 columns with a sing cell with a long list of associated targets, ex. C1: ABC-1, ABC-2... ABC-10, ABC-11, etc...to about ABC-20.
The macro looks at a raw data sheet with a User ID in a column and all targets in an offset cell. User ID in A1:A20 "123456789" and in B1:B20 is the target ABC-1...ABC20.
The macro loops through the raw data User ID column. When Raw data User ID is found in the Sheets1 User ID column A, it looks secondarily at the offset in the raw data and deletes anything not present in the long list on on the Sheets1 offset target list.
The issue I'm having is that sometimes -- and only sometimes -- the macro will read ABC-1 and take it as ABC-1x where x is any number making that target 10, 11, ... 18, 19.
Is there a way to correct for this without changing the target ID to ABC-01 (which I know is the easiest way but I' handcuffed there.
Macro loops from the bottom.
I am running a masking macro that uses data on a sheet (Sheets1) where column A has the User ID, ex. A1: A) 123456789, and then an offset 2 columns with a sing cell with a long list of associated targets, ex. C1: ABC-1, ABC-2... ABC-10, ABC-11, etc...to about ABC-20.
The macro looks at a raw data sheet with a User ID in a column and all targets in an offset cell. User ID in A1:A20 "123456789" and in B1:B20 is the target ABC-1...ABC20.
The macro loops through the raw data User ID column. When Raw data User ID is found in the Sheets1 User ID column A, it looks secondarily at the offset in the raw data and deletes anything not present in the long list on on the Sheets1 offset target list.
The issue I'm having is that sometimes -- and only sometimes -- the macro will read ABC-1 and take it as ABC-1x where x is any number making that target 10, 11, ... 18, 19.
Is there a way to correct for this without changing the target ID to ABC-01 (which I know is the easiest way but I' handcuffed there.
Macro loops from the bottom.
VBA Code:
Sub Masking()
On Error Resume Next
Dim sampname As Range
Set sampname = Worksheets("CopyRawDataHere").Range("D23:D3094")
Dim i As Integer
For i = 3071 To 1 Step -1
'For Each cell In sampname
sampid = sampname.Cells(i).Value
trgt = sampname.Cells(i).Offset(0, 1).Value
If trgt = "B_atroph" Or trgt = "RNaseP" Or trgt = "16s" Then
Else
Dim ordid As Range
Set ordid = Worksheets("Orders").Range("A1:A400")
For Each cell In ordid
If InStr(1, cell.Value, sampid) > 0 Then
orders = cell.Offset(0, 2)
If InStr(1, orders, trgt) > 0 Then
Else: sampname.Cells(i).EntireRow.Delete
End If
End If
Next
End If
Next i
End Sub