+ Reply to Thread
Results 1 to 4 of 4

Word VBA for loop to iterate through each cell selected by mouse

  1. #1
    Registered User
    Join Date
    12-08-2017
    Location
    Minneapolis, MN
    MS-Off Ver
    Standard 2013
    Posts
    31

    Word VBA for loop to iterate through each cell selected by mouse

    I made this macro. I know a few lines are redundant but I thought that would be necessary to make it work. It still works to do what I want, but not across all cells I select- only in cell one.

    What I want it to do is paste GCR 8/13/2019 (current date) in all the cells selected, which are basically vertical columns. It's for long tedious workpaper checklists that I'm constantly having to fill out. I understand I can just type Ctrl+V but I like a challenge and being keyboard independent when I'm leaning back in my chair. Anyway I got my desired macro to work on first selected cell of my selected range but not each cell in the range. To try get it to work on them all, I've been studying the official Office Docs, selection, table, range, cells, cell, etc. I'm getting better at theory but when I try various things I think might work, I keep getting errors, mostly the "object does not support property or method" error.

    What I think I have to do is get a Cells object to get returned based on the range selected by the mouse (not cell, but cells, which are different objects, and which is a range object), which represents a collection of contiguous cells (I think). I think this is where I fail. Then I think I could do for loop to loop through all the cells, and then a cell.select() method to get a selection object, whereafter I can do the code that I know works, below. But I haven't figured it out. Any cheat code would be awesome.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    1,245

    Re: Word VBA for loop to iterate through each cell selected by mouse

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

  3. #3
    Registered User
    Join Date
    12-08-2017
    Location
    Minneapolis, MN
    MS-Off Ver
    Standard 2013
    Posts
    31

    Re: Word VBA for loop to iterate through each cell selected by mouse

    Thanks for your suggestions. They didn't work. First one was object doesn't support property or method. Second was a new error I never saw, method or data member not found.

    It could be noted I'm working with 3rd party checklists that have macros and such in them but as far as I know they behave like normal tables.

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    1,245

    Re: Word VBA for loop to iterate through each cell selected by mouse

    Sorry, I didn't "notice" it was about the Ms Word ...
    Could you attach a sample document (doc) with a table (of course with false data to protect data confidentiality).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

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