TRUE instead of a number

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
571
Office Version
  1. 365
  2. 2019
  3. 2010
Platform
  1. Windows
I am working on a large document.
In the macro, this line of code

Sheets("backstage").Range("adjStaffCurRow").Value = Selection.Row

should yield the row number in my cell named adjStaffCurRow

Instead, I get "TRUE"

I have had this issue in other areas as well, using a list index where instead of saying the correct row number, I get TRUE as a result.

This is using Excel 2007.

Am I missing something? I have asked this question before and still have no solution. I would really appreciate any assistance in correcting this error.

Thanks in advance,
Glen
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
That is a logical statement. If you want the row,

Code:
myRow = Worksheets("backstage").Range("adjStaffCurRow").Row
 
Upvote 0
I am still getting stuck on this one.

I want to be in a cell on Sheet X
I want the vba to identify the row number, let's assume it is 16
I want a named cell on my backstage tab to then have the value of 16

Here is the code I am using to do this
Sheets("backstage").Range("adjStaffCurRow").Value = Selection.Row

Instead of a 16, sometimes it gives the number, other times it says TRUE

I clearContents of my adjStaffCurRow elsewhere so that is is always starting from empty.

This suggested code works to give me temporary storage
myRow = Worksheets("backstage").Range("adjStaffCurRow").Row
because another macro may or may not need to go to cell A16 in this case
range("A" & Range("adjStaffCurRow").value)

What am I missing here?
Please help
 
Upvote 0
This updates a named range called Boo in the current workbook with whatever is in the activecell ( which is whatever cell you've highlighted )

Code:
Sub UpdateNamedRangeFromActiveCell()
 
ActiveWorkbook.Names("Boo").RefersToRange = ActiveCell.Value
End Sub

so highlight a cell with data and run this macro

for row number

ActiveWorkbook.Names("Boo").RefersToRange = ActiveCell.Row
 
Upvote 0
This just gives me the cell contents. I need to store the active row number.

When I change it to refers to activecell.row, I get TRUE again

I need the number.
 
Upvote 0
Sheets("backstage").Range("adjStaffCurRow").Value = Selection.Row
should yield the row number in my cell named adjStaffCurRow
Instead, I get "TRUE"
I regret to report that when I try this here (Excel 2007), I always get the row number of the selected range exactly where I (and you) were expecting it - never a value of TRUE (or FALSE for that matter).

What happens if you set this scenario up in a completely new workbook?
 
Upvote 0
The issue seems to be that I get the number one time, but if I do the same macro again, I get TRUE.

This creates a debug error.
I stop and start over and it works fine.

I cannot have clients doing this. Any ideas?
 
Upvote 0
Charles, I copied both the active cell line and

ActiveWorkbook.Names("Boo").RefersToRange = ActiveCell.Row

The code works every second time.

I haven't tried it in a new workbook, but this workbook contains over 30 sheets and about 40 pages of code. I really don't want to start over
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,351
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top