Subnet Id

kjacw

Board Regular
Joined
Jun 29, 2010
Messages
144
Hello all
I need help with finding the closest number to a cell reference. I am familiar with using macros and written a few, but I'm at a loss on this one.
I am trying to find the closet number to my cell refenece O2 which is 77, I have a range to look in F3:F11. The number it finds will always be smaller larger than cell reference O2 but not larger. For example it will be between 64 and 96 but the number to be selected and stored in a variable is 64.
Thanks, I hope that helps. I am using Excel 2013 on Win 10 64bit.
 

Attachments

  • subnet.JPG
    subnet.JPG
    9.7 KB · Views: 6

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
How about
VBA Code:
Int(Range("O2") / 32) * 32
 
Upvote 0
How about
VBA Code:
Int(Range("O2") / 32) * 32
I'm sorry Fluff, Yes that one worked what you gave me but here is what i'm after.
1. My search number is O2,
2. Subnet Column is N2 (If my subnet falls within one of these subnets, the search needs to take place in this column). Another variable will supply this info

So it all depends on which subnet N2 and my search number O2, then the result will then be stored into a variable and used accordingly.

Sorry for the confusion or lack of other info. I have uploaded the pics below. I just don't know how to write code to say find my search number, ex 119 in the 32 Subnet column and tell me what number is it close to.

Thanks for the quick reply
 

Attachments

  • Search Range.PNG
    Search Range.PNG
    12.1 KB · Views: 5
  • Octet Rng _ Search number.PNG
    Octet Rng _ Search number.PNG
    1.8 KB · Views: 5
Upvote 0
Not quite sure what you are after but perhaps
VBA Code:
   Dim a As Long, b As Long
   a = Range("N2").Value
   b = Int(Range("O2") / a) * a
 
Upvote 0

Forum statistics

Threads
1,215,597
Messages
6,125,741
Members
449,256
Latest member
Gavlaar

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