Results 1 to 10 of 604

Thread: Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,323
    Rep Power
    10
    Number stored as text, alignment of numeric values in cells

    Improved/ Extended Evaluate Range solution. Recap General Purpose solution
    In a few posts time we will discusses extending the last solution to overcome a couple of problems that may occur with certain types of range data, specifically, if there may be empty cells or cells with real text in it. In this and the following 2 posts we will recap and come up with a general purpose solution to then go on and modify.

    General all purpose version of our final Evaluate Range solution Range variable, Rng
    Let us both standardise and recap on a good general purpose version of our Evaluate Range solution, with emphasis on learning and test and developing

    Range variable, Rng
    It’s probably more often than not a good idea to use a variable for our main data range. In technical terms we might re say that, as a variable for our main Range object. Using a variable for things is often a good idea, and particular a good idea for a range object, since Excel and Excel is all about boxes and manipulating them, and in VBA in particular, we have a lot of useful built in things like Methods, Properties, and the such, that we can use on them/ with them, in particular the range object since that is in particular to do with the box, and boxes structure that Excel is all about.
    So for some test range, such as A1:F7,
    https://i.postimg.cc/nctNH0WJ/Range-A1-F7.jpg
    Range(A1 F7).JPG
    , then somewhere towards the start of any macro we might have something like this
    Dim Rng As Range
    _Set Rng = Worksheets.Item("Sheet1").Range("A1:F7")

    You can often get away without the Worksheets.Item("Sheet1"). , if you know what you are doing and are sure that Excel will guess correctly which worksheet you are wanting to refer to, but often in a final coding, Excel may guess wrong, so more fully referencing a range is a good habit to get into.
    We may as well, from the start of our coding get fully into such good habits, and use a variable for the worksheet also
    Dim Ws1 As Worksheet
    _Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1")
    Dim Rng As Range
    _Set Rng = Ws1.Range("A1:F7")

    This Rng is referring to the test data range……._
    Attached Images Attached Images
    Last edited by DocAElstein; 08-14-2023 at 01:14 PM.

Similar Threads

  1. Testing Concatenating with styles
    By DocAElstein in forum Test Area
    Replies: 2
    Last Post: 12-20-2020, 02:49 AM
  2. testing
    By Jewano in forum Test Area
    Replies: 7
    Last Post: 12-05-2020, 03:31 AM
  3. Replies: 18
    Last Post: 03-17-2019, 06:10 PM
  4. Concatenating your Balls
    By DocAElstein in forum Excel Help
    Replies: 26
    Last Post: 10-13-2014, 02:07 PM
  5. Replies: 1
    Last Post: 12-04-2012, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •