I am trying to read a cell value in an excel with vba. When i try to read it I always get null.
Here is the code snippet
Private Sub CommandButton1_Click()
Dim i As Long
Dim j As Long
i = 3
j = 4
Do While (Len(Trim(Sheet1.Cells(i, 16))) <> 0)
Sheet2.Cells(4, j) = Sheet1.Cells(i, 16)
j = j + 1
i = i + 1
Loop
End Sub
But the dowhile always gets NULL and comes out of the loop. The cell in sheet1 has value in it.
Please help me out here.
NullintovbNull... - Kazimierz JaworNothingAnother way Which is my favIf Len(Trim(Sheet1.Cells(i,16).Value)) <> 0 ThenThis will ignore spaces pressed by mistake in a cell - Siddharth RoutIsEmpty: When Ipaste valuesto turn formulas into fixed values, some cells can be empty butisEmptyis false (they are treated as non-empty with ATL-Cursor-keys). Then possibly=""can be better sometimes thanIsEmpty. - KekuSemau