+ Reply to Thread
Results 1 to 11 of 11

How to amend the code when the Data starts other than Row 1

  1. #1
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    535

    How to amend the code when the Data starts other than Row 1

    Hi,

    I have the below code which works fine when the data starts in Row 1, but when the data starts other than row 1 it does give the expected result. Where I can change the row numbers in the below code when data starts at 2 or 3.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    577

    Re: How to amend the code when the Data starts other than Row 1

    a = Sheets("Report").Cells(1).CurrentRegion.Value
    NOTE: As the original poster/owner, only you can mark your thread as SOLVED (Thread Tools above Post #1).
    You can say "Thanks" in your thread to everyone who offered to help you.
    You can also reward them by clicking * "Add Reputation" under their username on the left.
    With Regards, MikeVol.

  3. #3
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    535

    Re: How to amend the code when the Data starts other than Row 1

    Quote Originally Posted by MikeVol View Post
    a = Sheets("Report").Cells(1).CurrentRegion.Value
    I tried, but the result what I get is something else.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,569

    Re: How to amend the code when the Data starts other than Row 1

    If data starts at row 3 change A2 to A3.
    Please Login or Register  to view this content.
    Also change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Last edited by bakerman2; 07-04-2025 at 04:57 PM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    535

    Re: How to amend the code when the Data starts other than Row 1

    Thanks, it works. But sometimes the columns will increase or decrease. In this case
    Please Login or Register  to view this content.
    wont work.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,569

    Re: How to amend the code when the Data starts other than Row 1

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    577

    Re: How to amend the code when the Data starts other than Row 1

    One more option for you:
    Please Login or Register  to view this content.
    Here we determine from which row the data on the sheet starts dynamically, without strictly specifying the row number. Good luck.

  8. #8
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    535

    Re: How to amend the code when the Data starts other than Row 1

    @MikeVol,

    Thanks for your excellent solution.

  9. #9
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    535

    Re: How to amend the code when the Data starts other than Row 1

    @bakerman2,

    Thanks, below code works

    Please Login or Register  to view this content.

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,569

    Re: How to amend the code when the Data starts other than Row 1

    You're welcome and thanks for rep+.

  11. #11
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    577

    Re: How to amend the code when the Data starts other than Row 1

    @Barieq Thanks for rep.+.

+ 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. Amend code to paste data into different column
    By telhearne1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2022, 06:07 AM
  2. [SOLVED] amend code merge duplicated data
    By ABDELFATTA in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-25-2020, 05:09 PM
  3. [SOLVED] Amend code to copy after last row where there is data
    By flupsie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2018, 01:07 AM
  4. Replies: 1
    Last Post: 08-08-2017, 10:25 AM
  5. [SOLVED] trying to amend this code to auto save new data
    By steve400243 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2017, 10:47 AM
  6. [SOLVED] Amend code to check cell A2 has data in before running
    By robertguy in forum Excel General
    Replies: 2
    Last Post: 12-11-2016, 09:13 AM
  7. Amend VBA Code to Clear Data
    By Renleff in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-26-2014, 04:15 PM

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