PDA

View Full Version : [SOLVED:] Loop in for used many columns



Nader
02-09-2012, 09:18 PM
This code is to auto fit one column. but I have many columns so I'll write the same code many times, but this its not professional.

exlWorkSheet.Columns("a:a").EntireColumn.AutoFit()
I treid to insert loop to columns but I don't know how to do this.

For i As Integer = 0 To exlWorkSheet.Columns.Count - 1
exlWorkSheet.Columns(.......).EntireColumn.AutoFit()
Next

Nader
02-09-2012, 09:22 PM
I found the answer now. the columns is lie a Range

exlWorkSheet.Columns("a:m").EntireColumn.AutoFit()