Need help in Filling Excel sheets - Interesting one

arjunmca

New member
Joined
May 16, 2007
Messages
2
Programming Experience
3-5
Hi,

I am filling excel sheet cells with the column names. Suppose if i want to insert data in "A1" cell , I am getting the ASC value of an integer(65) and concatinating the row value to the result and inserting the value in that cell.

Dim i as integer
Dim Num as integer=65
Dim chr As String
with excel.worksheet
For i = 1 To count
chr = System.Convert.ToChar(Num)
.Range(chr & "1").Value = i
Next

So the value are filling from A1.....Z1. But after Z1, the cell name starts with AA, AB, AC.......AZ, BA,BB......BZ, CA,CB,..........CZ.

Then i made a string like "AA" and try to insert the data in to that.
But its giving error. How to insert the data in to "AA" dynamically.

I will be greateful to you if any one suggested me in this regard.

Thanks,






To get the column name dynamically i am using ToChar() function ASC char for an integer.
 
You don't say which version of Excel you're using and I'm really rusty with Excel so I can't help you with the exact code but:

Excel worksheets have Columns and Rows properties. You should be able to use those to generate a range.

Please stop double and triple posting to different categories here in this forum.
 
Filling excel cells with column names

Hi,

I am using MicroSoft Excel 2003.

Hi,

I am filling excel sheet cells with the column names from A ....Z.

excelworksheet.Range("A1").Value = Name

excelworksheet.Range("Z1").Value = Name / working fine upto here

After Z1 the column name starts with "AA".

excelworksheet.Range("AA").Value = Name / Giving Error.

How to insert data in " AA " column ?

Thanks,
 
Back
Top