+ Reply to Thread
Results 1 to 8 of 8

Recorded Macro works in same cells every time

  1. #1
    Registered User
    Join Date
    09-23-2017
    Location
    Toronto, ON
    MS-Off Ver
    Microsoft Office 365 Subscription MSO (Version 2310 Build 16.0.1
    Posts
    52

    Exclamation Recorded Macro works in same cells every time

    Hello All,
    I using recorded macro in my workbook. Recorded macro works in same cell every time.
    I want to use macro on different cells when I use macro.

    For example:
    If I copy data from "Sheet1" and paste as transpose (convert data from row to column) in worksheet "2016", and in Worksheet "2016", I would like to format pasted table rows (in worksheet 2016) with cell borders(A60 to A68) <<- See attached video link
    Every time I run recorded macro, its only works in A60 to A68 cells and override on existing data. If I paste data in work sheet "2016" and run macro worksheet "2016" in cell A75 to A83, its should not move from there.


    Video File and Sample file are attached with details. Please help me out if possible.

    Many thanks in advance.

    Thank You.
    Attached Files Attached Files
    Last edited by nevernine9; 05-01-2023 at 02:10 PM.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Recorded Macro works in same cells every time

    Explain in detail and in a concise manner what needs to be done. Include cell names, ranges, sheet names etc.
    I quickly looked at the code and in 7 lines you have 4 times "select" which is totally unnecessary but that is another topic.
    To give you a start:
    "If I copy data". From which range in what sheet?
    "paste as transpose". In which sheet and where? Which column? First empty cell in that column? A particular cell?
    "format cell". This is just a single cell. Is that the cell where you start the paste transposed in?
    I have not checked but what is "All Border"?
    "delete top two rows". I assume in the sheet where you paste your data. Like Rows 1 and 2?
    In your code in one of the macros you have "Range("A60").Select" and then a paste line. That's where it will paste but according to your request, that's not what you want.

    If this macro is what you have in mind, you can extend it for the rest.
    Please Login or Register  to view this content.
    Congratulations with the Maple Leafs making the next round.
    Last edited by jolivanes; 04-30-2023 at 11:18 PM.
    Experience trumps academics every day of the week and twice on Sunday.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Recorded Macro works in same cells every time

    And this MIGHT satisfy all your needs.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Recorded Macro works in same cells every time

    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Registered User
    Join Date
    09-23-2017
    Location
    Toronto, ON
    MS-Off Ver
    Microsoft Office 365 Subscription MSO (Version 2310 Build 16.0.1
    Posts
    52

    Re: Recorded Macro works in same cells every time

    @jolivanes. Thank you for your reply.

    I apologize for not providing clear information.

    If I copy data from "Sheet1" and paste as transpose (convert data from row to column) in worksheet "2016".
    In Worksheet "2016", I would like to format pasted table rows (in worksheet 2016) with cell borders(A60 to A68) << - See attached video link
    Every time I run recorded macro, its only works in A60 to A68 cells and override on existing data. If I paste data in work sheet "2016" and run macro worksheet "2016" in cell A75 to A83, its should not move from there.

    in short - Macro is moving cells where its recorded and created.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Recorded Macro works in same cells every time

    Have you tried the macros from Post #3 and Post #4?
    AFAIK, they do what you require.

  7. #7
    Registered User
    Join Date
    09-23-2017
    Location
    Toronto, ON
    MS-Off Ver
    Microsoft Office 365 Subscription MSO (Version 2310 Build 16.0.1
    Posts
    52

    Re: Recorded Macro works in same cells every time

    @jolivanes & @sintek

    Works perfect !!!
    I really appreciate you helping me with this. Thank you so much both of you.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Recorded Macro works in same cells every time

    Thanks for letting us know and good luck with your Toronto Maple Leafs.

+ 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. [SOLVED] Recorded macro TexttoColumn doesn't works
    By danusko in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2020, 04:32 AM
  2. Replies: 1
    Last Post: 05-16-2019, 01:25 PM
  3. Change a recorded macro so it works for the "Active Tab" and not a specified tab.
    By almst791 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2017, 02:44 PM
  4. [SOLVED] Recorded Macro returns Run-time error '1004'
    By absconditus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-05-2015, 04:56 AM
  5. Replace works not in recorded VBA
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2014, 09:35 AM
  6. Recorded pivot macro run time error 5
    By cindywylie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2014, 08:38 PM
  7. [SOLVED] VBA to calculate the amount of time that falls between the time recorded in two cells.
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-17-2012, 02:39 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