PDA

View Full Version : Excel cell value as string won't store



ituarte
07-30-2015, 06:36 AM
Hello,

I have some values on row and I want to store one by one in a variable [string], the problem is that after "rec" it, the string is empty.

For example I have on the row 17 and colum from F to N, diferent values, first one, F17 is "65" and the following code:


Dim reg_a As String
Dim reg_b As String


For x = 6 To 14

reg_a = Sheets("Sample_1").Cells(x, 17).value
reg_b = Sheets("Sample_1").Range("F17").value

...

Next x

After the first reading, reg_a is "" and reg_b is "65"

Why it is? How can I solve the problem?

Thanks in advance

JKwan
07-30-2015, 07:04 AM
that's because you have your variables in reverse, it is (ROW, COLUMN)



.Cells(17, x)

ituarte
07-31-2015, 12:36 AM
hahaha , you are right, I wasted more than 1 hour on it.


Thanks