So my code is just supposed to autofill Column "H" and "I" with "0" and "1", respectively. It works just as it is supposed to, however for some reason when it gets to a certain section, it turns into dates (eg "1/0/1900", "1/1/1900". Not sure why it only does it to certain cells and not others. Here is my code:
Sub company()
With Sheets("Combined")
.Columns("A:XFD").NumberFormat = "Number"
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("H2:H" & LastRow).Value = 0
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("I2:I" & LastRow).Value = 1
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("A2:A" & LastRow).Value2 = "P"
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("C2:C" & LastRow).Value2 = 7
Sheets("Combined").Select
End With
End Sub
您可以将数字格式应用于列,以确保数字的正确外观,例如
Columns("H:I").NumberFormat = "0"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.