Consulting

Results 1 to 3 of 3

Thread: Excel cell value as string won't store

  1. #1
    VBAX Regular
    Joined
    Jul 2015
    Posts
    6
    Location

    Excel cell value as string won't store

    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

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    that's because you have your variables in reverse, it is (ROW, COLUMN)

       .Cells(17, x)

  3. #3
    VBAX Regular
    Joined
    Jul 2015
    Posts
    6
    Location
    hahaha , you are right, I wasted more than 1 hour on it.


    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •