+ Reply to Thread
Results 1 to 17 of 17

not sure why my code isn't doing anything... no bugs though!!!

  1. #1
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    not sure why my code isn't doing anything... no bugs though!!!

    I have the following code that does not come up with any errors when it is run, but it also doesn't do what I want it to...

    I have multiple sheets and will be adding more as time goes on, they are all in a similar format other than some of them start a bit further down but the bit that I need is over 20 rows hence the start and endline dims to find this range, then I want to copy the row (10 columns long) to the data sheet where the button is that activates this.

    I can't figure out why it isn't working...

    the code is as follows

    Please Login or Register  to view this content.
    help is greatly appreciated

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: not sure why my code isn't doing anything... no bugs though!!!

    What is this loop meant to, well, loop through?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    A list of cells with dates in

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: not sure why my code isn't doing anything... no bugs though!!!

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

    Does the data start in Row 3, or does cell A3 contain a value that specifies where the data starts?

  5. #5
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    cell A3 contains a value that specifies where the data starts,

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: not sure why my code isn't doing anything... no bugs though!!!

    Hi,

    What Norie was alluding to is the fact that the line
    Please Login or Register  to view this content.
    should actually read
    Please Login or Register  to view this content.
    otherwise the code will not loop at all.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: not sure why my code isn't doing anything... no bugs though!!!

    OK - Then StartLine (and EndLine) need to be declared as Longs - not Range.

    Next issue.

    You refer to 'Cells' regularly. No problem with that but, when unqualified, 'Cells' will refer to the active sheet (probably 'Data'), not whichever sheet you may be checking.

    Please Login or Register  to view this content.
    Should be
    Please Login or Register  to view this content.
    As an aside, VBA is case sensitive by default. If A1 contains 'Active' then that statement will not be True.

    All references to ranges should be qualified with a reference to the worksheet. For example:
    Please Login or Register  to view this content.
    Should (probably) be
    Please Login or Register  to view this content.
    Last edited by cytop; 06-21-2017 at 06:07 AM.

  8. #8
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    Thank you,

    I have changed it but it still doesn't work

  9. #9
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    i have changed

    Please Login or Register  to view this content.
    to


    Please Login or Register  to view this content.
    and now i get an error "Run time error '91': object variable or With block not set"

    not sure why that is happening :O

  10. #10
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: not sure why my code isn't doing anything... no bugs though!!!

    Then StartLine (and EndLine) need to be declared as Longs - not Range
    No mention of changing the declarations...

  11. #11
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    whoopsie, I have changed it now,

    the code doesn't have any bugs now but it still doesnt do anything,

    current version as follows

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: not sure why my code isn't doing anything... no bugs though!!!

    Now the issue is this line.

    Please Login or Register  to view this content.
    'Empty' is a tricky thing to use, the actual syntax should be
    Please Login or Register  to view this content.
    I think that's the last issue...

  13. #13
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    woohoooooo!!! thank you so much!!!

    for anyone interested or also stuck I had to change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: not sure why my code isn't doing anything... no bugs though!!!

    As mentioned in post #7.

  15. #15
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    i thiought as I referenced the ws in the
    Please Login or Register  to view this content.
    that I wouldn't need it in the other parts

  16. #16
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: not sure why my code isn't doing anything... no bugs though!!!

    Nope... any reference to a range (or Cells) must be qualified with the worksheet name or VBA will assume the active sheet...

    Not saying this is any better than yours, but is just what I ended up with ...
    Please Login or Register  to view this content.
    You should include
    Please Login or Register  to view this content.
    at the top of the module so string comparisons are not case sensitive, otherwise you should explicitly convert to upper/lower case to compare
    Please Login or Register  to view this content.
    Last edited by cytop; 06-21-2017 at 07:15 AM.

  17. #17
    Registered User
    Join Date
    02-27-2017
    Location
    kent
    MS-Off Ver
    2007
    Posts
    41

    Re: not sure why my code isn't doing anything... no bugs though!!!

    works a charm! thank you so much!

+ 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. I keep getting random bugs in a fairly complex code (for me neways)... works sometimes tho
    By Legend Rubber in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2013, 08:39 AM
  2. reporting bugs in Excel?
    By moonfish in forum Excel General
    Replies: 4
    Last Post: 05-02-2011, 01:36 PM
  3. VBA Unhiding Rows Bugs...
    By V8Maverick in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2010, 07:42 AM
  4. no bugs, cell just not filling
    By ritz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2007, 06:10 PM
  5. Fixing some bugs
    By daddioja in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-19-2006, 01:35 PM
  6. excel bugs
    By jiggy in forum Excel General
    Replies: 1
    Last Post: 06-16-2006, 10:55 PM

Tags for this Thread

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