I'm writing a VBA program that writes the results from mathematical equations into cells. To print the output in the proper cells I write:
'Print output
Sheets(1).Cells(4, 16) = Output_t1
Sheets(1).Cells(4, 17) = CapitalStock_t1
Sheets(1).Cells(4, 18) = Consumption_t1
Sheets(1).Cells(4, 19) = Investment_t1
Sheets(1).Cells(4, 20) = Government_t1
Sheets(1).Cells(4, 21) = TotalDeadWtLoss_t1
Sheets(1).Cells(4, 22) = Energy_Usage_Consumption_t1
Sheets(1).Cells(4, 23) = Energy_Usage_Production_t1
Sheets(1).Cells(4, 24) = Energy_Usage_t1
Sheets(1).Cells(4, 25) = AtmoEmissions_t1
At first, the program was working fine. Then for some unknown reason, VBA started putting the output in the wrong cells. What was suppose to be in one cell was put into another cell. I'm so confused which number was put into what cell, that I'm too confused to tell you. But if I write the output like this, then the numbers are in the right cell.
'Print output
Sheets(1).Cells(4, 16) = Output_t1
Sheets(1).Cells(4, 17) = CapitalStock_t1
Sheets(1).Cells(4, 18) = Consumption_t1
Sheets(1).Cells(4, 19) = Investment_t1
Sheets(1).Cells(4, 20) = Government_t1
Sheets(1).Cells(4, 24) = TotalDeadWtLoss_t1
Sheets(1).Cells(4, 21) = Energy_Usage_Consumption_t1
Sheets(1).Cells(4, 22) = Energy_Usage_Production_t1
Sheets(1).Cells(4, 23) = Energy_Usage_t1
Sheets(1).Cells(4, 25) = AtmoEmissions_t1
The numbers are now in the right cells, but it's very confusing because Cells(4, 24) should correspond to cell X4, but the number is being written now in Cell U4. Somehow, my Excel/VBA program started jumbling the column numbering system. Is there a fix or do I have to use the unusual labeling system, where the numbering system is out of order.
'Print output
Sheets(1).Cells(4, 16) = Output_t1
Sheets(1).Cells(4, 17) = CapitalStock_t1
Sheets(1).Cells(4, 18) = Consumption_t1
Sheets(1).Cells(4, 19) = Investment_t1
Sheets(1).Cells(4, 20) = Government_t1
Sheets(1).Cells(4, 21) = TotalDeadWtLoss_t1
Sheets(1).Cells(4, 22) = Energy_Usage_Consumption_t1
Sheets(1).Cells(4, 23) = Energy_Usage_Production_t1
Sheets(1).Cells(4, 24) = Energy_Usage_t1
Sheets(1).Cells(4, 25) = AtmoEmissions_t1
At first, the program was working fine. Then for some unknown reason, VBA started putting the output in the wrong cells. What was suppose to be in one cell was put into another cell. I'm so confused which number was put into what cell, that I'm too confused to tell you. But if I write the output like this, then the numbers are in the right cell.
'Print output
Sheets(1).Cells(4, 16) = Output_t1
Sheets(1).Cells(4, 17) = CapitalStock_t1
Sheets(1).Cells(4, 18) = Consumption_t1
Sheets(1).Cells(4, 19) = Investment_t1
Sheets(1).Cells(4, 20) = Government_t1
Sheets(1).Cells(4, 24) = TotalDeadWtLoss_t1
Sheets(1).Cells(4, 21) = Energy_Usage_Consumption_t1
Sheets(1).Cells(4, 22) = Energy_Usage_Production_t1
Sheets(1).Cells(4, 23) = Energy_Usage_t1
Sheets(1).Cells(4, 25) = AtmoEmissions_t1
The numbers are now in the right cells, but it's very confusing because Cells(4, 24) should correspond to cell X4, but the number is being written now in Cell U4. Somehow, my Excel/VBA program started jumbling the column numbering system. Is there a fix or do I have to use the unusual labeling system, where the numbering system is out of order.