+ Reply to Thread
Results 1 to 6 of 6

unable to write data to sheet using currentRegion.Rows.Count

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    New Delhi
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    37

    Exclamation unable to write data to sheet using currentRegion.Rows.Count

    hi,

    I am using the below code to write data to excel sheet using a userform but, it shows 'Run-time error '9': subscript out of range.

    the code I am using is:

    Please Login or Register  to view this content.
    continued.......


    please help on this
    Last edited by JBeaucaire; 05-22-2014 at 12:39 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: unable to write data to sheet using currentRegion.Rows.Count

    That error means VBA cannot find the object you supplied by name. The sheet "datasheet" perhaps can't be found.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: unable to write data to sheet using currentRegion.Rows.Count

    Hi,

    try
    Please Login or Register  to view this content.
    IŽd go with using the end-command from the bottom to find the last used row and offset from there.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    03-25-2013
    Location
    New Delhi
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    37

    Re: unable to write data to sheet using currentRegion.Rows.Count

    Quote Originally Posted by JBeaucaire View Post
    That error means VBA cannot find the object you supplied by name. The sheet "datasheet" perhaps can't be found.
    Shall I rename the datasheet to default sheet1 and update code?

    please advice if there are other alternatives.

    Thanks

  5. #5
    Registered User
    Join Date
    03-25-2013
    Location
    New Delhi
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    37

    Re: unable to write data to sheet using currentRegion.Rows.Count

    Quote Originally Posted by HaHoBe View Post
    Hi,

    try
    Please Login or Register  to view this content.
    IŽd go with using the end-command from the bottom to find the last used row and offset from there.

    Ciao,
    Holger
    The code seems to be similar with the one I have worked on.

    Please check and advice any othet alternatives.

    thanks

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: unable to write data to sheet using currentRegion.Rows.Count

    Hi, sumit dey,

    Please check and advice any othet alternatives.
    ShouldnŽt you at least try the code posted here and report back opposed to using wrong commands in your sample and asking me to update a code which at least is showing the proper commands?

    Bye,
    Holger

+ 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. Replies: 0
    Last Post: 04-02-2012, 04:28 PM
  2. Write new data rows to a new sheet based on data in sheet 1
    By NickPovey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2011, 10:08 AM
  3. Alternative to CurrentRegion.Columns.Count?
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-04-2011, 12:51 PM
  4. Macro: Count rows in sheet A, copy count in sheet B, paste offset in sheet A
    By Agent:Orange in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2011, 07:56 AM
  5. Replies: 2
    Last Post: 04-12-2010, 10:52 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