+ Reply to Thread
Results 1 to 3 of 3

Editing Contents of Active (selected) Cells

  1. #1
    Registered User
    Join Date
    08-28-2018
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    2

    Editing Contents of Active (selected) Cells

    Hi. I'm very new to VBA & macros... just a beginner!

    I wish for my VBA procedure to affect my currently selected cells (one or more), wherever they may be.
    The selected cells may already contain various values... example: 88.12345 and 99.54321.
    For each cell selected, I'd like to take those starting values and wrap them in a 2-decimal 'round' formula... example: =round(88.12345,2) and =round(99.54321,2). Any selected cells that were blank before running my VBA should remain blank after.

    Here's what I've got so far... obviously, it's not working:

    Please Login or Register  to view this content.
    Above... i've tried breaking the 'round' formula into two halves and declared each half a string (RoundA and RoundB)... and then inserting the current cell value between the two strings of the formula... and then reinserting the whole new formula (RoundA + initial cell value + RoundB) back into the selected cell.

    Not clear which to use - activecell.formula vs activecell.value - in this instance; hence, using ' to keep one as a placeholder for the time being.

    Anyways, if someone could please tell me the error or my ways, and set me straight on how to accomplish what I want, I'd be very grateful.

    Thank you so much!
    Last edited by Richard Buttrey; 08-28-2018 at 07:37 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Editing Contents of Active (selected) Cells

    Hi and welcome to the forum

    Here's one way

    Please Login or Register  to view this content.
    Incidentally please note our forum rule about wrapping code in code tags. I've changed your original but please note for the next time.

    One other point. Whilst you can position your Dim statements anywhere you want (as long as it's before the first instance) it's normal practice to put all Dim statements as the first lines of code in a procedure.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-28-2018
    Location
    Toronto
    MS-Off Ver
    2016
    Posts
    2

    Re: Editing Contents of Active (selected) Cells

    2nd try at replying... think I hit the wrong 'reply' button to send it. If the 1st shows up later, my bad! Anyways...

    Thanks so much, Richard. Wow... your solution is so much cleaner/simpler than what I'd been gnawing at; I'll have to study/learn from what you've shown me, thanks!

    And thanks for the tips. Didn't realize there was a '#' button to apply to code text... now I do.

    Cheers!

+ 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. Replies: 19
    Last Post: 07-19-2017, 10:43 AM
  2. [SOLVED] Editing all Cells in a selected range.
    By Joachimjr in forum Excel General
    Replies: 9
    Last Post: 07-09-2014, 08:24 AM
  3. [SOLVED] setting variables for 2 cells on active selected row
    By wanty in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2013, 06:00 PM
  4. [SOLVED] Display contents of multiple active cells in another cell?
    By mtsykes28 in forum Excel General
    Replies: 2
    Last Post: 06-14-2012, 11:27 AM
  5. InputBox selects active cell, not selected cells?
    By kidmiuso in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2010, 09:50 AM
  6. Check selected cells are right of active cell
    By papata123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2007, 02:10 PM
  7. How to set the position of a active cell and clear the contents of the cells
    By aijihz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2007, 04:46 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