0

I am trying to use vba to do some data mining. I have excel spreadsheet and writing a code to select data from a row. Each column has separate variables but the row represents all the variables for that particular set.

I want to write a for loop for selecting a cell and assigning the value of that cell to a particular variable.

For counter = 7 To 57

Ca = Worksheets("sheet1").Cells(g, counter)

What would be correct syntax to assign value of say cell g7 to variable Ca?

Thank you, AJ

4

1 回答 1

0

将say cell g7的值分配给变量Ca的正确语法是什么?

Ca = Worksheets("sheet1").Cells(7, 7)

Syntax : .Cells(Row,Column)

同样G8会是Cells(8,7)

或者

Ca = Worksheets("sheet1").Range("G" & counter)

Where counter is 7

将此应用于您的代码

你可以写你的代码

For counter = 7 To 57

Ca = Worksheets("sheet1").Cells(g, counter)

作为

For counter = 7 To 57
    Ca = Worksheets("sheet1").Cells(counter,7)

或者

For counter = 7 To 57
    Ca = Worksheets("sheet1").Range("G" & counter)
于 2012-05-21T18:39:26.860 回答