+ Reply to Thread
Results 1 to 8 of 8

VBA code to divide all cells in a dynamic column by 60

  1. #1
    Registered User
    Join Date
    12-29-2019
    Location
    Australia
    MS-Off Ver
    2012
    Posts
    3

    VBA code to divide all cells in a dynamic column by 60

    Hello eveybody,

    I'm looking to create a VBA button that'll quickly allow me to change the units of a duration variable. I have been able to write the code and get it to run smoothly, however when the number rows in the column changes (e.g. theres a new set of data i need to change the units for. For example 6 sets of data instead of 20) the code tries to divide multiple columns by 60.

    Please Login or Register  to view this content.
    Thanks for your help in advance,

    Cheers,

    Stan
    Last edited by Pepe Le Mokko; 12-29-2019 at 10:00 AM.

  2. #2
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    422

    Re: VBA code to divide all cells in a dynamic column by 60

    Please SEE THE FORUM RULES

    YOU NEED TO use # buttom to put the codes
    If you think someone helped you, click on the "* Add Reputation" as a way to say thank you.

    If your problem is solved, go to Thread Tools and select Mark This Thread Solved

  3. #3
    Forum Guru Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2010 on Linux
    Posts
    11,281

    Re: VBA code to divide all cells in a dynamic column by 60

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I did it for you this time. Please read forum rules. Thanks
    Be very, very careful using IFERROR ! It hides ALL errors which is not always what you want to get correct results

  4. #4
    Registered User
    Join Date
    12-29-2019
    Location
    Australia
    MS-Off Ver
    2012
    Posts
    3

    Re: VBA code to divide all cells in a dynamic column by 60

    Apologies for my mistake! Thanks for the prompt assistance though.

    Stan

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

    Re: VBA code to divide all cells in a dynamic column by 60

    Re: "multiple columns"
    Any "Merge and Center" Ranges in there by chance?
    If so, get rid of them. Change to "Center across Selection".

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

    Re: VBA code to divide all cells in a dynamic column by 60

    Maybe there is zero in some cell ?

  7. #7
    Registered User
    Join Date
    12-29-2019
    Location
    Australia
    MS-Off Ver
    2012
    Posts
    3

    Re: VBA code to divide all cells in a dynamic column by 60

    I believe the code is okay considering it runs smoothly when I just run the macro. However, when I attach the macro to a button it selects a larger range and won't execute the code.

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

    Re: VBA code to divide all cells in a dynamic column by 60

    "it selects a larger range"
    If there is no data, it will mark the entire column from top to bottom, attach an xls example, it doesn't have to be true but it should be appropriate, adequate.

+ 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. Code to recgonize non-numeric "Left"/start of cell in cells of dynamic column
    By horrockc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2016, 10:19 AM
  2. [SOLVED] Take Cells from one column and divide up in multiple columns
    By robkrouse in forum Excel General
    Replies: 5
    Last Post: 09-01-2016, 11:00 AM
  3. VBA code to divide the last row from column A-J by the last row from column K.
    By psingh2688 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-26-2015, 02:31 PM
  4. [SOLVED] Divide a Cell by the number of populated cells in a column
    By MATU70 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 04-11-2014, 06:49 AM
  5. [SOLVED] Using underscore ("_") with Cells().formula, to divide the code in multiple lines
    By Mayda89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2013, 03:42 PM
  6. [SOLVED] Macro/VB Code to Divide Worksheet into several New Files By Column
    By mabiem in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-30-2013, 12:50 PM
  7. Dynamic Find and Divide
    By biker123456 in forum Excel General
    Replies: 0
    Last Post: 10-26-2009, 06:06 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