1

Oddly enough, I am surprised that I cannot find this information online! I am trying to use the following code:

If Cells(RowCount, 215).Value = "Edge Roughness" Then
    sb.Append "ER"
End If

The cell needs to be an exact match to the text string. For example, some cells are just "Width" while some are "Width Roughness"

Can somebody explain why I cannot use the Cells(RowCount, 215) command? Key note: it has to be variable so that I can use the RowCount command.

4
  • Dunno, why can't you? Cells(1,215) is the 215th column on the first row ... what happens when you use it? Commented Aug 3, 2015 at 16:03
  • Application defined or object defined error. I can post the entire code if necessary. Commented Aug 3, 2015 at 16:04
  • Yes as what you have should work Commented Aug 3, 2015 at 16:06
  • Are you referring to a cell on another workbook? and what is the value of RowCount when you get this error? How does RowCount get it's value. Please supply the full code. Commented Aug 3, 2015 at 16:09

1 Answer 1

2

You can use range. It is for the worksheet.

Range("A" & RowCount).Value
Sign up to request clarification or add additional context in comments.

3 Comments

This does not allow me to use the variable RowCount
Can I do Range("A"RowCount)?
Sure it does, the declaration is just a little different. You'd need to convert the column number to a column letter then use Range(columnLetter & RowCount).Value. You can also do Range("A" & RowCount).Value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.