+ Reply to Thread
Results 1 to 8 of 8

Offset(9,0) positive number used Negative numbers to retrieve data

  1. #1
    Registered User
    Join Date
    04-24-2020
    Location
    USA
    MS-Off Ver
    365
    Posts
    12

    Offset(9,0) positive number used Negative numbers to retrieve data

    Hi Everyone,
    I am not understanding how this is working...

    Attached you will find a simple workbook 1 sheet 1 column of data 9 rows long when the user form is up and you click the button the following executes

    Dim editvalue As Range
    Dim EV As Range
    Dim nb As Integer
    Dim LRow As Long
    Dim LListRow As Long
    Dim BMatch As Boolean
    Dim tmp As String
    Dim tmp2 As String
    Dim ColumnNumber As Long
    Dim x As Integer

    tmp = ""

    Worksheets("Position Packs").Select
    Set editvalue = Sheet9.Range("C:EE").Find(what:=emppack, LookIn:=xlValues)
    tmp = editvalue.Address(0, 0)
    'Convert To Column Number
    'ColumnNumber = Range(tmp & 1).Column
    ColumnNumber = Range(tmp).Column
    nb = WorksheetFunction.CountA(Columns(ColumnNumber))

    (Positive) 'nb=9

    Set editvalue = Sheet1.Range("C:EE").Find(what:=emppack, LookIn:=xlValues).Offset(nb, 0)

    (Negative) For x = -1 To -nb Step -1

    Me.tb1.Value = editvalue.Offset(x, 0)
    Stop

    Next

    Trying the for x with 1 thru 9 does not work (Positive numbers as they were pulled).

    but when I go to retrieve the data I need to use a negative number and I do not understand why?
    I only want to pull the 8 entries under the header "ALL".

    Also, I'm all ears and eyes if there is a better way to do this.

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,027

    Re: Offset(9,0) positive number used Negative numbers to retrieve data

    Rather than trying to decipher your code, it might be easier to help if you could include a detailed explanation of what you would like to do referring to specific cells, rows, columns and worksheets.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    04-24-2020
    Location
    USA
    MS-Off Ver
    365
    Posts
    12

    Re: Offset(9,0) positive number used Negative numbers to retrieve data

    I did it is below the code.

    Thank you

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,027

    Re: Offset(9,0) positive number used Negative numbers to retrieve data

    Is the macro doing what you wanted?

  5. #5
    Registered User
    Join Date
    04-24-2020
    Location
    USA
    MS-Off Ver
    365
    Posts
    12

    Re: Offset(9,0) positive number used Negative numbers to retrieve data

    yes, but not as expected.
    I originally made the For x = 0 to 9 loop

    with positive numbers and got no results.... Used negative numbers (just to find the data) and found the data That's the part I do not get??!!??

    with offset going up in a column is negative.. but I'm reading down (Positive) but getting the data with neg number -1 through -9, not 1-9??


    Mumps1 I do Apologize if I am not making sense here.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,027

    Re: Offset(9,0) positive number used Negative numbers to retrieve data

    The way your code is written, the variable "editvalue" will return as empty with no value. What is the expected result based on your data? Also, why are you searching C:EE for the word "ALL"? If you explain in words what you are trying to do, step by step, to get the expected result, it would be easier to follow.

  7. #7
    Registered User
    Join Date
    04-24-2020
    Location
    USA
    MS-Off Ver
    365
    Posts
    12

    Re: Offset(9,0) positive number used Negative numbers to retrieve data

    Ok here is what I would like to accomplish.

    1. Search for Header in this case "ALL" and read the data below it.

    2. with the data from list "ALL" search list#2 for match and use this as the result.

    Thanks

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,027

    Re: Offset(9,0) positive number used Negative numbers to retrieve data

    Where is list #2 and what values do you want to match?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calculating number of negative or positive numbers.
    By Oblisgr in forum Excel General
    Replies: 3
    Last Post: 05-24-2018, 04:30 PM
  2. Count negative numbers in row of data after the last positive number
    By jamintech in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-20-2017, 06:52 PM
  3. Count negative numbers in row of data after the last positive number
    By jamintech in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2017, 04:08 PM
  4. [SOLVED] SUMIF positive and negative numbers - take double a negative number?
    By Zordrail in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2014, 08:34 AM
  5. [SOLVED] Determine whether number of positive numbers exceeds number of negative numbers
    By HRBP in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-04-2012, 09:49 PM
  6. Convert negative to positive in sheet containing both positive/negative numbers
    By sa02000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2010, 07:52 PM
  7. Replies: 1
    Last Post: 11-20-2008, 01:52 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1