+ Reply to Thread
Results 1 to 18 of 18

Find Values without Decimal places in a Range/Column of DATA

  1. #1
    Registered User
    Join Date
    04-12-2019
    Location
    Cardiff
    MS-Off Ver
    2019
    Posts
    18

    Find Values without Decimal places in a Range/Column of DATA

    Hello all,

    I have a simple spreadsheet of data with values such as
    1
    1.1
    1.2
    2
    2.2
    2.3
    3

    I Would like to Find the values without decimal places and highlight them

    the code i have so far is

    Please Login or Register  to view this content.
    but i get a run time error 1004 on line 1

    my questions are
    is this code suitable?
    what could be causing the runtime error?
    Last edited by Johndotcom; 05-15-2024 at 06:06 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,836

    Re: Find Values without Decimal places in a Range/Column of DATA

    Maybe use
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,836

    Re: Find Values without Decimal places in a Range/Column of DATA

    Full code (untested):

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-04-2014
    Location
    Portugal
    MS-Off Ver
    XL2013/XL365
    Posts
    91

    Re: Find Values without Decimal places in a Range/Column of DATA

    It may give an error since "2.1" can be a string, depending on the system and then Int(cell.Value) gives an error.

  5. #5
    Registered User
    Join Date
    04-12-2019
    Location
    Cardiff
    MS-Off Ver
    2019
    Posts
    18

    Re: Find Values without Decimal places in a Range/Column of DATA

    Hello Trevor - Manchester is a Great City, was there a couple of years ago and loved it.

    As for the suggestion, thank you, this is a better method but now I would like to elaborate further

    when I find the range without the decimal I would like to add a new row.

    I am using this at the moment

    Please Login or Register  to view this content.
    however, it stops at the first found range without the decimal and does not pass and go to the next cell.

  6. #6
    Registered User
    Join Date
    04-12-2019
    Location
    Cardiff
    MS-Off Ver
    2019
    Posts
    18

    Re: Find Values without Decimal places in a Range/Column of DATA

    I was because Range A1:A contained a # and blank so i changed it to

    Please Login or Register  to view this content.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,836

    Re: Find Values without Decimal places in a Range/Column of DATA

    You're welcome.

    Sharing a sample workbook (in future) helps mitigate issues that cannot be seen or guessed at


    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon (Next to Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  8. #8
    Registered User
    Join Date
    04-12-2019
    Location
    Cardiff
    MS-Off Ver
    2019
    Posts
    18

    Re: Find Values without Decimal places in a Range/Column of DATA

    Quote Originally Posted by TMS View Post
    Full code (untested):

    Please Login or Register  to view this content.
    Hello Trevor - Manchester is a Great City, was there a couple of years ago and loved it.

    As for the suggestion, thank you, this is a better method but now I would like to elaborate further

    when I find the range without the decimal I would like to add a new row.

    I am using this at the moment


    Please Login or Register  to view this content.
    however, it stops at the first found range without the decimal and does not pass and go to the next cell.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,836

    Re: Find Values without Decimal places in a Range/Column of DATA

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: Find Values without Decimal places in a Range/Column of DATA

    To my understanding this should help.

    Please Login or Register  to view this content.
    Like when deleting rows you start at the bottom and work your way up. Same principal here.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,836

    Re: Find Values without Decimal places in a Range/Column of DATA

    @bakerman2: I agree that you should start from the bottom as the range doesn't auto-adjust in the loop, so you could stop too soon. However, I want to see the file as I don't understand why it would stop after the first cell.

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: Find Values without Decimal places in a Range/Column of DATA

    Trevor, just did the test and it keeps adding rows after cell A1. I stopped the code and when I stepped through the code with F8 my lastrow suddenly was 20000+.

    Like you said yourself the range doesn't auto-adjust in the loop.

  13. #13
    Registered User
    Join Date
    04-12-2019
    Location
    Cardiff
    MS-Off Ver
    2019
    Posts
    18

    Re: Find Values without Decimal places in a Range/Column of DATA

    Quote Originally Posted by bakerman2 View Post
    To my understanding this should help.

    Please Login or Register  to view this content.
    Like when deleting rows you start at the bottom and work your way up. Same principal here.

    You have understood what I've asked for and it works like a charm, if you could see the size of the program I'm developing you would understand why its difficult for me to send the files. thanks all.

  14. #14
    Registered User
    Join Date
    04-12-2019
    Location
    Cardiff
    MS-Off Ver
    2019
    Posts
    18

    Re: Find Values without Decimal places in a Range/Column of DATA

    Thank you all for your advice, i can take information from all of you that makes my work much better,/

  15. #15
    Registered User
    Join Date
    04-12-2019
    Location
    Cardiff
    MS-Off Ver
    2019
    Posts
    18

    Re: Find Values without Decimal places in a Range/Column of DATA

    The Plot has thickened and I need your help again on this topic, therefore I have added two excel workbooks that shows what I start with and what I would like to end with

    the finished code looks like this now, however it fails when presented with numbers such as 4.1.1

    Please Login or Register  to view this content.
    I'm a little perplexed buy this problem, I wounder if you are able to find the solution. I thank you all again.
    Attached Files Attached Files

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,914

    Re: Find Values without Decimal places in a Range/Column of DATA

    Since I'm using comma as decimal sign I'm getting correct results when running code.

    Maybe try something like this.

    Please Login or Register  to view this content.

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

    Re: Find Values without Decimal places in a Range/Column of DATA

    What if you use Instr?
    Please Login or Register  to view this content.
    You should not need both the full stop and the comma.
    Experience trumps academics every day of the week and twice on Sunday.

  18. #18
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: Find Values without Decimal places in a Range/Column of DATA

    If from top to bottom try like this, another way you can using typename(cells(j,1).value), or varType(cells(i,j).value)
    Please Login or Register  to view this content.
    Last edited by daboho; 05-16-2024 at 08:13 PM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

+ 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] Max 2 decimal places for result / Integers 0 decimal places
    By djc123 in forum Excel General
    Replies: 6
    Last Post: 09-10-2022, 08:28 AM
  2. Replies: 4
    Last Post: 07-09-2022, 12:23 PM
  3. Need help with filtering values with 3 decimal places
    By dougers1 in forum Excel General
    Replies: 7
    Last Post: 02-09-2022, 08:42 AM
  4. Decimal Places in referenced values.
    By dontaylor in forum Excel General
    Replies: 4
    Last Post: 02-15-2016, 12:28 PM
  5. find decimal Places in data sheet
    By dan789 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-02-2015, 01:41 AM
  6. [SOLVED] Round all values in a column to two decimal places
    By The Phil in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-09-2015, 03:09 PM
  7. Finding Values With more than 2 decimal Places
    By clane in forum Excel General
    Replies: 7
    Last Post: 06-22-2005, 03:37 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