Good morning all!
I have data in ColumnA, with what can be, a random, number of blanks between them. I wanted to format the cell directly under any cell in columnA where data exists, to use "Free 3 of 9 Extended" font. The code below works beautifully for that, and only formats the cells directly below the cell where data exists, in columnA.
Sub AddBarcodeToPart()
Dim c As Range, sh1 As Worksheet
Set sh1 = Sheets("Pick List")
For Each c In sh1.Range("A6", Cells(Rows.Count, "A").End(xlUp))
If c.Value <> "" Then
c.Offset(1, 0).Font.Name = "Free 3 of 9 Extended"
End If
Next
End Sub
However, when I try to use a similar code, to add the formula needed to make it a readable barcode, it adds the formula to every cell instead of the just the offset reference. (It also doesn't add the needed quotes around the * correctly to make this a readable barcode).
Sub ValueForBarcode()
Dim c As Range, sh1 As Worksheet
Set sh1 = Sheets("Pick List")
For Each c In sh1.Range("A6", Cells(Rows.Count, "A").End(xlUp))
If c.Value <> "" Then
c.Offset(1, 0).Formula = "*" & c & "*"
End If
Next
End Sub
Any ideas what I could be doing wrong here? (I am sure there are probably better ways to achieve my desired result, but this is my starting point)
Thanks in advance for any help!
I have data in ColumnA, with what can be, a random, number of blanks between them. I wanted to format the cell directly under any cell in columnA where data exists, to use "Free 3 of 9 Extended" font. The code below works beautifully for that, and only formats the cells directly below the cell where data exists, in columnA.
Sub AddBarcodeToPart()
Dim c As Range, sh1 As Worksheet
Set sh1 = Sheets("Pick List")
For Each c In sh1.Range("A6", Cells(Rows.Count, "A").End(xlUp))
If c.Value <> "" Then
c.Offset(1, 0).Font.Name = "Free 3 of 9 Extended"
End If
Next
End Sub
However, when I try to use a similar code, to add the formula needed to make it a readable barcode, it adds the formula to every cell instead of the just the offset reference. (It also doesn't add the needed quotes around the * correctly to make this a readable barcode).
Sub ValueForBarcode()
Dim c As Range, sh1 As Worksheet
Set sh1 = Sheets("Pick List")
For Each c In sh1.Range("A6", Cells(Rows.Count, "A").End(xlUp))
If c.Value <> "" Then
c.Offset(1, 0).Formula = "*" & c & "*"
End If
Next
End Sub
Any ideas what I could be doing wrong here? (I am sure there are probably better ways to achieve my desired result, but this is my starting point)
Thanks in advance for any help!