View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
DPCpresto via OfficeKB.com DPCpresto via OfficeKB.com is offline
external usenet poster
 
Posts: 4
Default Formatting Col C based on data in Col B

Aloha Rob, I'll give your code a try and see how it works...sorry for the
confusion of my description...

Dave

Rob van Gelder wrote:
Your instructions aren't all that clear. In places it could be interpreted multiple ways.
In any case, I've done my best, and probably you'll be able to nut something out based on the code supplied.

Sub test()
Const cFirstRow = 2
Const cCheckCol = "B", cDestCol = "C"

Dim i As Long, lngLastRow As Long, bln As Boolean

With ActiveSheet
lngLastRow = .Cells(Rows.Count, cCheckCol).End(xlUp).Row

'up front check for ML* W*
bln = False
For i = cFirstRow To lngLastRow
If Left(.Cells(i, cCheckCol), 3) = "ML*" Or _
Left(.Cells(i, cCheckCol), 2) = "W*" Then
bln = True
Exit For
End If
Next

For i = cFirstRow To lngLastRow
If bln Then .Cells(i, cDestCol) = .Cells(i, cDestCol) & "ABC"

If InStr(1, .Cells(i, cCheckCol), "*105*") 0 Or _
InStr(1, .Cells(i, cCheckCol), "*SR*") 0 Or _
InStr(1, .Cells(i, cCheckCol), "*KBV*") 0 Or _
InStr(1, .Cells(i, cCheckCol), "*KR*") 0 Then
.Cells(i, cDestCol) = .Cells(i, cDestCol) & "DEF"
Else
.Cells(i, cDestCol) = .Cells(i, cDestCol) & "ABC"
End If
Next

End With
End Sub

Cheers,
Rob

I have to format a report every day that is imported from SQL to Excel. My
problem is that I am stuck on trying to "insert" text descriptions in Column

[quoted text clipped - 20 lines]
will be inserted into the macro I already have. Any assistance would be
appreciated.


--
DPCpresto

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1