Excel Macro Format Problem
Excel Macro Format Problem
(OP)
I have the following in a macro:
For i = 1 To endRow
PN = ActiveCell.Value
EC1 = ActiveCell.Offset(0, 1).Value
If EC1 = "" Then GoTo Next_PN
For j = 3 To Worksheets.Count
Sheets(j).Activate
Range("B4").Activate
ACV = ActiveCell.Value
If ACV = PN Then
ActiveCell.Offset(0, 16).Value = EC1
My If check never finds a match because PN=1234 and ACV="1234". Originally PN was formatted general and ACV as text. I reformatted ACV as general but I still don't get a match. How do I fix this?
For i = 1 To endRow
PN = ActiveCell.Value
EC1 = ActiveCell.Offset(0, 1).Value
If EC1 = "" Then GoTo Next_PN
For j = 3 To Worksheets.Count
Sheets(j).Activate
Range("B4").Activate
ACV = ActiveCell.Value
If ACV = PN Then
ActiveCell.Offset(0, 16).Value = EC1
My If check never finds a match because PN=1234 and ACV="1234". Originally PN was formatted general and ACV as text. I reformatted ACV as general but I still don't get a match. How do I fix this?





RE: Excel Macro Format Problem
Instead of = try Like
----------------------------------
Hope this helps.
----------------------------------
maybe only a drafter
but the best user at this company!
RE: Excel Macro Format Problem
RE: Excel Macro Format Problem
it appears that the vba code sees PN as a number and ACV as text, regardless of formatted type. while the "like" comparason may suffice the needs, the cell function =value(B4) converts text to a numeric value. hence, the comparason can be made with like data (i.e. comparing numbers).
good luck!
-pmover
RE: Excel Macro Format Problem
Apparently the guy who started these files formatted everything in the top x lines as text. Had he left them as general I think everything would have worked.