Help with Existing VBA code

C

Cam

Hello,

I have the following existing code which look at a column "I" and if the
word "ASC" text is present in the cell, then skip filling the data in column
I thru N for the row.
What I would like to change the code so that it will fill the data in the
cell from column I thru N that does not have "ASC" on the cell. Thanks

Old code sample:
A I J K L M N
Line# 1300 1300 1500 1500 1700 1700
001 ASC
002 x x x x x x
003 x x x x x x

skip row 2 with line# 001 cause ASC is in column I2 so skipping cell J2 thru
N2). Where x is data that the macro fill in.

New code wanted:
A I J K L M N
Line# 1300 1300 1500 1500 1700 1700
001 ASC x ASC x x x
002 x ASC x x x x
003 x x x x x x

it does not skip row 2 with line# 001, but rather fill in the missing cell
(J2, L2, M2 and N2) without "ASC" in the cell.

Here is my existing code:

Sub InsertData(ByRef MyArray() As Variant, _
Count, Ref, Model, InsertSheet)

With Sheets(InsertSheet)
RowCount = 2
MyOffset = 0
Do While (Not IsEmpty(.Cells(RowCount, "I")) And _
(.Cells(RowCount, "H") <> Model)) Or _
(.Cells(RowCount, "I") = "ASC") Or _
(.Rows(RowCount).Hidden = True)

RowCount = RowCount + 1
Loop

For LoopCount = 0 To (Count - 1)
.Cells(RowCount, "I"). _
Offset(0, (2 * Ref) + MyOffset) = _
MyArray(LoopCount, SO)
.Cells(RowCount, "Q"). _
Offset(0, (2 * Ref) + MyOffset) = _
MyArray(LoopCount, OP)

If MyOffset = 0 Then
.Cells(RowCount, "H").Value = Model
MyOffset = 1
Else
RowCount = RowCount + 1
Do While (Not IsEmpty(.Cells(RowCount, "I")) And _
(.Cells(RowCount, "H") <> Model)) Or _
(.Cells(RowCount, "I") = "ASC") Or _
(.Rows(RowCount).Hidden = True)

RowCount = RowCount + 1
Loop
MyOffset = 0
End If
Next LoopCount

End With
 

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

Top