+ Reply to Thread
Results 1 to 7 of 7

How to get VBA to ignore "blank" cells or cells with "text"

  1. #1
    Forum Contributor
    Join Date
    04-28-2016
    Location
    Stavanger, Norway
    MS-Off Ver
    365
    Posts
    142

    How to get VBA to ignore "blank" cells or cells with "text"

    Im trying to get my script to ignore all blank cells or cells with text but I cant seem to manage.
    I tried this but it didnt work;

    Sub Knapp3_Klikk()

    If IsError(myvalue = Application.Match(tosearch, Range("K1:K100"), 0)) Then
    GoTo nextloop:
    Dim olddeg As Range, newval As Double
    For Each olddeg In Range("K2:K99999").CurrentRegion
    newval = 360 + 90 - olddeg
    olddeg.Offset(0, 0) = newval - (newval \ 360) * 360

    Next olddeg

    End Sub

    Any idea?

    Thanks

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: How to get VBA to ignore "blank" cells or cells with "text"

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    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



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Forum Contributor
    Join Date
    04-28-2016
    Location
    Stavanger, Norway
    MS-Off Ver
    365
    Posts
    142

    Re: How to get VBA to ignore "blank" cells or cells with "text"

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: How to get VBA to ignore "blank" cells or cells with "text"

    The intention was for you to edit your original post with code tags, but I guess that is close enough.

    Not really following what you're trying to do from the snippet of code you've provided, assuming that you want to test olddeg for a numeric value, try

    Please Login or Register  to view this content.
    Not so sure that the use of CurrentRegion is a good idea though, you could quite easily end up running the code on incorrect columns.

  5. #5
    Forum Contributor
    Join Date
    04-28-2016
    Location
    Stavanger, Norway
    MS-Off Ver
    365
    Posts
    142

    Re: How to get VBA to ignore "blank" cells or cells with "text"

    Okay so I would like my angles to get converted from polar angles to North Azimuth system using the following code

    Please Login or Register  to view this content.
    But the code stops if any cells in column A contains text or if any of them are empty.
    So I would like the script to ignore any cells with text or without any data and just continue from Cell A1 to A10000.
    Sorry If my question wasnt clear. I hope this helps

    Best regards

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: How to get VBA to ignore "blank" cells or cells with "text"

    See if this works.

    Please Login or Register  to view this content.
    Using current region would also include any adjacent 'used' columns, for example if you had your data in column A, with a heading in B1 ready for the column of new values, then column B would be included in the current region. Subsequently the values that the code writes into column B would then be recalculated, and entered (incorrectly) into column C.

  7. #7
    Forum Contributor
    Join Date
    04-28-2016
    Location
    Stavanger, Norway
    MS-Off Ver
    365
    Posts
    142

    Re: How to get VBA to ignore "blank" cells or cells with "text"

    Awesome, your a lifesaver! Thanks

    Regards

+ 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] Copy cells from range "C3" to "F3" with loop and blank field
    By masterm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2015, 01:03 PM
  2. Data Validation - how to ignore cells with "0" or "-"
    By dgibney in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-29-2015, 08:16 PM
  3. [SOLVED] Keeping particular cell blank if the related cells show "0" or "blank"
    By Anuru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-24-2014, 05:30 AM
  4. [SOLVED] Replace all BLANK cells in column with header title "Balance" to "0"
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2014, 09:25 AM
  5. Replies: 5
    Last Post: 01-23-2014, 11:02 AM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. making graphs ignore "blank " cells
    By Guillermo in forum Excel General
    Replies: 4
    Last Post: 02-22-2005, 06:06 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