this macro is hypothetically going to find the widest entry in each column, and then write that width in a new inserted top row. My problem is it doesn't like my cell assignments (even when they are exactly like cell assignments I've done in the past! any idea why it hates this line no matter how I program it?
ActiveSheet.Cells(0, ccount) = 0
ActiveSheet.Cells(0, ccount).Value = 0
Cells(0, ccount) = 0
Cells(0, ccount).Value = 0
Full code is this
Sub WidthCounter()
Rows("1:1").Select
Dim ccount As Integer
ccount = Selection.Cells.SpecialCells(xlCellTypeConstants).Count
MsgBox (ccount)
Columns("A:A").Select
Dim rcount As Integer
rcount = Selection.Cells.SpecialCells(xlCellTypeConstants).Count
MsgBox (rcount)
ActiveCell.EntireRow.Insert
rcount = rcount + 1
For a_counter = 1 To ccount
ActiveSheet.Cells(0, ccount) = 0
For b_counter = 2 To rcount
temp = Len(Cells(rcount, ccount).Value)
If (temp > Cells(0, ccount).Value) Then Cells(0, ccount).Value = temp
Next b_counter
Next a_counter
End Sub
Bookmarks