Find returning value not range

epactheactor

New Member
Joined
Sep 9, 2015
Messages
38
Hello,

I'm attempting to use a find function in my code. Yet, when I run it, it puts the value of the cell into the variable and not the range.

Could someone please tell me what i am doing wrong?

Code:

Sub Saving_Crack()


Dim IDnum As String
Dim filePath As String
Dim crackIDnum As Range
Dim wt As Variant
Dim crackIDwkbk As String
Dim a As Range


'to get the ID number


crackIDwkbk = ActiveWorkbook.Name
Sheets("Properties").Activate
IDnum = Range("B2").Value




'go to masterlist
Windows("Check Defect Data Inputs").Activate
Set crackIDnum = Range("B1:B123").Find(IDnum)
Debug.Print crackIDnum




'flaw label as a variable
Range(crackIDnum).Offset(0, 15).Value = wt

End Sub

Code:
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
It is putting the range object into the variable not the cell value, if you use
Code:
Debug.Print crackIDnum.Address
you can see that.
Also this line
Code:
Range(crackIDnum).Offset(0, 15).Value = wt
should be
Code:
crackIDnum.Offset(0, 15).Value = wt
 
Upvote 0
So say the find function finds ("B3") as the range that contains the value. By removing the Debug Print statement the variable will be the range of B3?
 
Upvote 0
The variable will be Range("B3") with or without the Debug.Print line.

Debug.Print does not change the variable it simply prints information to the Immediate window.
 
Upvote 0

Forum statistics

Threads
1,224,876
Messages
6,181,519
Members
453,050
Latest member
Obil

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