Hey everyone,
I am working with Excel and have hit a wall and hopefully someone can give me a hand. I have a list that determines the number of columns data needs to be entered into Excel. With each run, the user can pick the number of items they want to view so the Excel will expand and shrink depending on the user. Also, the user has the ability to add items to the list whenever they want so the code needs to be able to expand freely into never before used columns.
I'm using this code to help me throw the Excel Formulas into the row & column it belongs.
The problem now is, I'm entering data row by row in the sheet and I need to change the formula up on most of the cells.
I can't put this into my loop
since it depends on what row & column the loop is at which is in a variable.
I'm trying to figure out if there is a way to convert the column number into the correct Excel column letter. So something like 5 = C, 20 = T, 30 = AD, 40 = AN and so on. I have the rows covered no problem but can't figure out a way to change the column to the correct letters.
I need something like this (which I know is totally incorrect)
that changes to this
My current way would be something like this
^^^^ I need the D & AA & AD to be changed from a LCol variable into those letters and not hardcoded.
Has anyone come across this problem? I'm thinking I might need to create a function to do it manually but hoping their is like a VFP command or VFP Function that can do this automatically that I don't know about. Any help will be greatly appreciated!
I am working with Excel and have hit a wall and hopefully someone can give me a hand. I have a list that determines the number of columns data needs to be entered into Excel. With each run, the user can pick the number of items they want to view so the Excel will expand and shrink depending on the user. Also, the user has the ability to add items to the list whenever they want so the code needs to be able to expand freely into never before used columns.
I'm using this code to help me throw the Excel Formulas into the row & column it belongs.
Code:
loxls.Cells(lRow, lCol).Value = [=A2 + B2]
The problem now is, I'm entering data row by row in the sheet and I need to change the formula up on most of the cells.
I can't put this into my loop
Code:
[=A2 + B2]
I'm trying to figure out if there is a way to convert the column number into the correct Excel column letter. So something like 5 = C, 20 = T, 30 = AD, 40 = AN and so on. I have the rows covered no problem but can't figure out a way to change the column to the correct letters.
I need something like this (which I know is totally incorrect)
Code:
loxls.Cells(lRow, lCol).Value = "=" + Cells(lRow, lCol) + " + " + Cells(lRow, lCol) + " / " + Cells(lRow, lCol)
Code:
loxls.Cells(lRow, lCol).Value = [=D33 + AA32 / AD33]
My current way would be something like this
Code:
loxls.Range([C] + lRow).Value = [=D] + lRow + [+AA] + Alltrim(Str(aa,5,0)) + [ / AD] + lRow
Has anyone come across this problem? I'm thinking I might need to create a function to do it manually but hoping their is like a VFP command or VFP Function that can do this automatically that I don't know about. Any help will be greatly appreciated!