Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

How to use a string inside a .Range in Excel VBA?

$
0
0

I would like your help with something i got stuck.

Basically i want to do a variable iRow, by finding a cell with the value OBRC , the cell that has this value is retrieved by the command find, then i got the value from the row and treat it as a string manipulating the string to get only the row number as exit, till this part was not a big deal. But when i need to use this string variable CellString as part of the range value it doesn't work.

I need this to make my script work,as i need this value to write the information on the spreadsheet, so i would like to know how can i solve it, i was thinking to convert this string as double but i dont know how to do it. Here is my code:

Function FindCell()

 Dim CellLocation As Range
 Dim CellString As String


    Set CellLocation = Sheets("Sheet1").Range("A1048576").Find("OBRC") ' retrieves the value OBRC + the row.

        CellString = Right(CellLocation.Text, 0) ' Manipulate the intire value OBEC + Row and retrieves only the row.

    With ThisWorkbook.Sheets("Sheet1")
            .Range("A"& CellString).Value = "Teste"'it concatenate the Column + the row, it should be working but is not


    End With



End Function

Fell free to give me any advice.


Viewing all articles
Browse latest Browse all 88835


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>