+ Reply to Thread
Results 1 to 5 of 5

Range Offset

  1. #1
    Registered User
    Join Date
    06-03-2015
    Location
    South Carolina
    MS-Off Ver
    2013
    Posts
    13

    Range Offset

    In one sheet, if the value in column A is "(HAT)" then the columns next to it are 123, 456, 789, 101, respectively. (These are made up data). The problem is those data are in another sheet and I am not sure how to reference them since VBA is in R1C1 form and the location of the data in the first sheet may change. This is what I currently have:


    For i = 0 To 40
    If Range("A1").Offset(i, 0).Value = "(HAT)" Then
    Range("C1").Offset(i, 0).Value = "123"
    Range("D1").Offset(i, 0).Value = "456"
    Range("E1").Offset(i, 0).Value = "789"
    Range("F1").Offset(i, 0).Value = "101"
    End If
    Next i

  2. #2
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Range Offset

    try:

    Please Login or Register  to view this content.
    this assumes your column A is in sheet1 and your data is to be sent to sheet2
    Got help? Pls give rep.
    If you do R&D learn VBA

  3. #3
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Range Offset

    alternatively use this for multiple rows:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-03-2015
    Location
    South Carolina
    MS-Off Ver
    2013
    Posts
    13

    Re: Range Offset

    I don't want the data sent to sheet2, I am pulling the data from sheet2 to be sent to sheet1. But the location of the data may change (if the user of this excel workbook adds rows in sheet1 or sheet2).

  5. #5
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Range Offset

    If you need to send the data to a different sheet then just change the names as needed.

    As for the size of the list, the current loops cycles all the way to row 40. If you need more rows just increment the 40 to a number bigger than the foreseeable size of the dataset. If that is not sufficient then there are many posts on this forum how to find the number of rows in a table

+ 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. [SOLVED] Problemas with object assignation in hierachy Range.Offset.Range
    By rensalzado in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-19-2014, 02:39 AM
  2. [SOLVED] Define new range names based on existing range name offset 1 column to right
    By jprlimey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-2014, 07:53 PM
  3. Replies: 1
    Last Post: 01-23-2013, 03:00 PM
  4. Dynamic Range using Offset, range not found for Pivot
    By GoneBaja in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-08-2012, 09:19 AM
  5. Replies: 2
    Last Post: 08-22-2005, 01:05 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