+ Reply to Thread
Results 1 to 7 of 7

read values from cells and compare them with preset values

  1. #1
    Registered User
    Join Date
    05-14-2013
    Location
    ksa
    MS-Off Ver
    Excel 2013
    Posts
    5

    read values from cells and compare them with preset values

    i have a range from 40 rows and open no. of columns
    i need vb program that performs the following
    1- read A5
    2- if A5 has value , program makes A5 red color and then go to A6 and make same action
    3- if A5 is empty , program goes to A6 and read A6 value make same action
    4- repeat until A45
    5- go to column 2 starting from B5 and repeat the same steps
    6- program stops at last empty column
    Last edited by AHMED_GWAD77; 09-23-2016 at 12:28 PM.

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: read values from cells and compare them with preset values

    Perhaps like this then? I assume when you say "empty" you mean a blank cell.

    Please Login or Register  to view this content.
    Alf

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: read values from cells and compare them with preset values

    You might use Conditional Formatting with the formula =(A1<>"") to turn the cells red rather than using VBA.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    05-14-2013
    Location
    ksa
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: read values from cells and compare them with preset values

    thank you for that
    it really helps
    i modified by adding time delay 1 second in each row or column scan
    but is there a code to give me delay time in milliseconds?
    Sub ChckRang()
    Dim cell As Range
    Dim i As Integer
    Dim j As Integer

    For i = 5 To 40
    Application.Wait (Now + TimeValue("00:00:1"))

    For j = 1 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column

    If Cells(i, j) <> "" Then
    Application.Wait (Now + TimeValue("00:00:1"))
    Cells(i, j).Interior.Color = vbRed

    End If

    Next

    Next

    End Sub
    Last edited by AHMED_GWAD77; 09-24-2016 at 09:54 AM.

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: read values from cells and compare them with preset values

    To stop macro for milliseconds you need to use API calls. See link

    http://www.myonlinetraininghub.com/p...leep-or-a-loop

    at the end of this page you can download "Code Samples" do so and check macro "SleepTest"

    Alf

  6. #6
    Registered User
    Join Date
    05-14-2013
    Location
    ksa
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: read values from cells and compare them with preset values

    thanks a lot , you really helped me

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: read values from cells and compare them with preset values

    You are welcome.

    And thanks for feedback

    Alf

    Ps If this solves your problem don't forget to mark thread "Solved"

    To mark your thread solved do the following:
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

+ 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] preset paste values
    By sfoll in forum Excel General
    Replies: 3
    Last Post: 08-01-2015, 06:09 AM
  2. modify UDF ConCatIf to read and compare one of two alternative values
    By Narayan~ in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 04-15-2013, 02:29 PM
  3. [SOLVED] How to round to preset values in Excel?
    By noobsaibot in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-26-2013, 01:29 AM
  4. How do I read data from one column, compare it to the values one next to it?
    By kih1251 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 06:15 PM
  5. Replies: 3
    Last Post: 07-05-2012, 11:09 AM
  6. Need help to convert numbers into preset values
    By christianlie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2010, 04:44 AM
  7. can excel draw with preset values
    By man57 in forum Excel General
    Replies: 6
    Last Post: 04-17-2006, 05:10 AM

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