+ Reply to Thread
Results 1 to 8 of 8

Clean my copy code?

  1. #1
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Clean my copy code?

    I don't know how to call the title!

    But i made a copy Macro. It is working nice. But it isn't nice coding! And i need 5 more just like it with different cells and columns.
    I'm sure there is a nicer way to code this and still understand what is going on so i can change it.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Clean my copy code?

    A bit better (I hope it will be working as it should):


    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Re: Clean my copy code?

    Works fine. Thanks.

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Clean my copy code?

    You welcome.
    If you happy with solution, please use Thread Tools and mark it as SOLVED.

    p.s. I will appreciate if You also add reputation point.

  5. #5
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Re: Clean my copy code?

    Learnt a lot. If i'm correct you cant set Dim with a letter you use in the code for a column. Is there a way to close the Dim en give it a new range?

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Clean my copy code?

    You can name Your variables as You wish (almost, except function names, etc.)
    So, don't worry I as variable can be use, like below:
    Range("I"&I).value
    so, depends on I value it can be reference to I1, I2 or whatever.
    You can rename it for Dim X as integer, as You wish, BUT from programming point of view X,Y,Z usually is set for variables which have to be calculated (as unknown on start) if you know what I mean.
    For simple integer to looping usually i,j or etc. are used.
    As I said as You wish.


    Of course when this loop is finish, You can start new:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Re: Clean my copy code?

    Quote Originally Posted by KOKOSEK View Post
    You can name Your variables as You wish (almost, except function names, etc.)
    So, don't worry I as variable can be use, like below:
    Range("I"&I).value
    so, depends on I value it can be reference to I1, I2 or whatever.
    You can rename it for Dim X as integer, as You wish, BUT from programming point of view X,Y,Z usually is set for variables which have to be calculated (as unknown on start) if you know what I mean.
    For simple integer to looping usually i,j or etc. are used.
    As I said as You wish.


    Of course when this loop is finish, You can start new:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Can you do it also with this? The other script is messing up the table. It has to be pasted at once. Because otherwise the table skips a line and the next value is a row down and not next to it.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Clean my copy code?

    Do the same loop (for i=6 to 13) for this:

    Please Login or Register  to view this content.

+ 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. Clean up code
    By g1terra in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-17-2017, 01:20 AM
  2. VBA Code clean up
    By DHHM in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2015, 03:41 AM
  3. Have VBA code that needs performed in multiple sheets. Also help being sure code is clean
    By baby_kay_2003 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-17-2014, 10:57 PM
  4. Clean up code
    By madhatter40 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2014, 09:21 AM
  5. [SOLVED] VBA Code to optimize and clean data- clean out numerical/ or symbol
    By tracylsr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-05-2012, 04:21 PM
  6. VBA code clean up help
    By recon427 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-17-2012, 01:19 AM
  7. Code clean up for workbook to workbook copy
    By bowhunt24 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-10-2011, 04:05 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