0

I'm working on a fixed width to CSV macro. The macro works as expected, the macro validates the field lengths vs the secondary file that houses the lengths to check. It is supposed to put the word "Pass" or "Fail" under the field lengths in the Excel row for each field. The problem is it only validates the first cell against the second cell and Auto Fills the rest based on the number of fields in a given file.

It needs to be able to validate each cell value against the field length vs validating the secondary file called "input_layout"

Range("B2").Select
Selection.AutoFill Destination:=Range(Cells(2, 2), Cells(2, col_count)), Type:=xlFillDefault
Range(Cells(2, 1), Cells(2, col_count)).Interior.ColorIndex = 6
ActiveSheet.Cells(3, 2).Formula = "=IF(B$1=B$2,""Pass"",""Fail"")"
Range("B3").Select
Selection.AutoFill Destination:=Range(Cells(3, 2), Cells(3, col_count)), Type:=xlFillDefault
Range(Cells(3, 1), Cells(3, col_count)).Interior.ColorIndex = 28
Range(Cells(1, 1), Cells(1, col_count)).Interior.ColorIndex = 39
GSerg
  • 76,472
  • 17
  • 159
  • 346
  • you have the rows locked. `B$1=B$2`. make them relative and it should work. you may want to review this link to help you writer more efficient code that will cause less problems in the future: [avoid select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – Scott Holtzman Apr 17 '19 at 16:27
  • I took the project over to make improvements to the code. When I was working on the code improvements that is when I noticed the expected count vs the actual count. Which starts in column B row 1 and row 2. It validates those two cells and does an auto fill. But when I change field lengths in the file that I'm testing the result row that puts "Pass" or "Fail" in does not actually work even unlocking the rows. – Nicholas Kuhlenbeck Apr 17 '19 at 17:08

0 Answers0