ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test a named cell in a macro (https://www.excelbanter.com/excel-programming/394028-test-named-cell-macro.html)

[email protected]

Test a named cell in a macro
 
I need to test a named cell in the excel sheet to see if there is any
data in the cell.

Currently I am doing:

'Req Number
If Trim(Cells(4, 7)) = "" Then
errtest = errtest & "Please Fill in the Req Number"
End If

The problem is that the cells 4,7 may change, as new lines get added
to the sheet. So I have named it ReqNo in the sheet. Then even if new
lines are added, the test will still be on the correct field.

But I don't know how to call it.

I have tried the following:
Cells("ReqNo")
Cells('ReqNo')
Activecell.ReqNo
select.cell.ReqNo
ect, ect , ect

Does anyone know how to call a named cell in the macro?

Cheers for all help,
Caroline


John Bundy

Test a named cell in a macro
 
Use range to select a named cell

ActiveSheet.Range("reqno") = "123"

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

I need to test a named cell in the excel sheet to see if there is any
data in the cell.

Currently I am doing:

'Req Number
If Trim(Cells(4, 7)) = "" Then
errtest = errtest & "Please Fill in the Req Number"
End If

The problem is that the cells 4,7 may change, as new lines get added
to the sheet. So I have named it ReqNo in the sheet. Then even if new
lines are added, the test will still be on the correct field.

But I don't know how to call it.

I have tried the following:
Cells("ReqNo")
Cells('ReqNo')
Activecell.ReqNo
select.cell.ReqNo
ect, ect , ect

Does anyone know how to call a named cell in the macro?

Cheers for all help,
Caroline




All times are GMT +1. The time now is 12:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com