+ Reply to Thread
Results 1 to 6 of 6

Event after For Loop

  1. #1
    Registered User
    Join Date
    02-08-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    7

    Event after For Loop

    Hi, I know this is really basic one but cant seem to figure it out how to simply select cell A1 after the loop runs

    I have a date contained in column F starting in row 3 through to row X (defined as number of entries in row A) and to get these to format correctly i need to individually select each cell and move through the loop - code below achieves this.

    where i am stuck, after the loop completes i simply want to select cell A1 in the active "Transactions" sheet

    Hopefully can point me in the right direction. Sorry for such a newbie one

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    06-02-2012
    Location
    London, England
    MS-Off Ver
    365
    Posts
    397

    Re: Event after For Loop

    Hi,

    I'm more than likely missing the point here, but does Range("A1").Select not work to do that?

    I'm confused as why you're doing what the rest of your code is for... Are you doing the F2/Enter thing because the dates are not in data format but text and you're coercing them into dates with that?

    If so then there could be a quicker and easier way than looping through them.

    Beth.

  3. #3
    Registered User
    Join Date
    02-08-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    7

    Re: Event after For Loop

    Quote Originally Posted by BanginMyHeadOnMyDesk View Post
    Hi,

    I'm more than likely missing the point here, but does Range("A1").Select not work to do that?

    I'm confused as why you're doing what the rest of your code is for... Are you doing the F2/Enter thing because the dates are not in data format but text and you're coercing them into dates with that?

    If so then there could be a quicker and easier way than looping through them.

    Beth.
    Hi Beth,
    Yes re the dates, are formatted as "Custom" data such as 29-Sep-2019. if i change the excel formatting to date it actually doesnt achieve the change. The only way i have figured out to do it is manually selecting each date cell and then pushing enter (hence the loop macro) and this gets them to a usable date format.

    if I add Range("A1").Select after the loop it selects this and starts working down row A instead of row F

    thanks a million for your help!
    Mark
    Last edited by markymark2345; 10-12-2019 at 01:22 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    06-02-2012
    Location
    London, England
    MS-Off Ver
    365
    Posts
    397

    Re: Event after For Loop

    I don't understand what you mean by "it starts working down column A". Is your code above called through a sheet change event or something? Why would selecting A1 start the loop again is what I mean.

    Anyway, perhaps try this approach.

    Please Login or Register  to view this content.
    TextToColumns has a quirky side effect that will change text dates to date format dates and saves you having to loop through one by one

    Beth.

  5. #5
    Registered User
    Join Date
    02-08-2015
    Location
    sydney
    MS-Off Ver
    2010
    Posts
    7

    Re: Event after For Loop

    Quote Originally Posted by BanginMyHeadOnMyDesk View Post
    I don't understand what you mean by "it starts working down column A". Is your code above called through a sheet change event or something? Why would selecting A1 start the loop again is what I mean.

    Anyway, perhaps try this approach.

    Please Login or Register  to view this content.
    TextToColumns has a quirky side effect that will change text dates to date format dates and saves you having to loop through one by one

    Beth.
    Thank you so much Beth - that works perfectly.... (and alot quicker!) thank you!!

  6. #6
    Valued Forum Contributor
    Join Date
    06-02-2012
    Location
    London, England
    MS-Off Ver
    365
    Posts
    397

    Re: Event after For Loop

    Happy to help

    Beth.

+ 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. Userform_Initialize event not running For/Next Loop
    By Quest2chill in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2012, 01:18 PM
  2. Endless Loop When Using BeforePrint Event
    By PosseJohn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-29-2011, 09:35 PM
  3. WS_Calculate Event doing funny loop
    By ron2k_1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2011, 10:21 AM
  4. Loop in canceling of event
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-30-2011, 07:14 PM
  5. Worksheet_Change Event Causing Loop
    By yawnzzzz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2009, 10:20 AM
  6. [SOLVED] Loop with Cell Change Event
    By Adrian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2006, 07:55 AM
  7. Loop with Cell Change Event:using VBA
    By Adrian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2006, 03:50 PM
  8. Change Event Endless loop :-(
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2005, 06:45 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