+ Reply to Thread
Results 1 to 8 of 8

date from net compare to today issuing type mis-match

Hybrid View

  1. #1
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    date from net compare to today issuing type mis-match

    any though here ...type mismatch on date.

    For Each rep In Rng1.Cells   '-> this is from...   Set Rng1 = .[a1:a1500]
             strMyChar = rep.Value
             replace = rep.Offset(0, 2).Value   '-> offset range to date location (range)
            strMyReplace = rep.Offset(0, 1).Value
                   With Rng2
                         If replace = Mydate Then    'type mismatch here
                               .replace What:=strMyChar, Replacement:=strMyReplace, _
                                SearchOrder:=xlByColumns, MatchCase:=True
                         End If
            End With
    Next rep
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: date from net compare to today issuing type mis-match

    It looks like you are comparing a string to a date. A date is a number.

    This would produce the same error...
    If "Text" = 1 Then
    How is MyDate declared and set?
    What exactly is in rep.Offset(0, 2).Value? A Serial date or a Text-date?
    How is replace declared?
    Last edited by AlphaFrog; 07-29-2013 at 09:23 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: date from net compare to today issuing type mis-match

    you mean the offset is returning a string instead of the number(date).
    i checked the dates they are numbers(i tried to add ) also formatted as *3/14/2001

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: date from net compare to today issuing type mis-match

    They are Serial dates

     Dim ws As Worksheet, wb As Workbook
        Dim fList As Variant, i As Integer
        Dim Rng1, Rng2, rep As Range
        Dim Mydate As Date
        Mydate = Date
       Dim strMyChar As String, strMyReplace As String
       Dim replace As String
               With ActiveWorkbook.Worksheets("Sheet4")
                        Set Rng1 = .[a1:a1500]  ' i set this up to 1500 rows incase there will be more updates
            End With
        With ActiveWorkbook.Worksheets("Data")
            Set Rng2 = .[A1:Z500]   ' this is the range where it will change all instances
        End With
         
        
           For Each rep In Rng1.Cells
           strMyChar = rep.Value
           replace = rep.Offset(0, 2).Value
            strMyReplace = rep.Offset(0, 1).Value
              With Rng2
               If replace = Mydate Then
                .replace What:=strMyChar, Replacement:=strMyReplace, _
                SearchOrder:=xlByColumns, MatchCase:=True
                 End If
            End With
              Next rep

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: date from net compare to today issuing type mis-match

    Dim Mydate As Date
    Dim replace As String
    MyDate is a Date.
    replace is a string and not a date.

  6. #6
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: date from net compare to today issuing type mis-match

    lol, Why did not I see that I was going round and round...
    Thank you very much.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: date from net compare to today issuing type mis-match

    You're welcome.

    Also note;
    Dim Rng1, Rng2, rep As Range
    In this declaration, only rep is type Range. Rng1 and Rng2 are both type variant unless you explicitly declare the type for each e.g.;
    Dim Rng1 As Range, Rng2 As Range, rep As Range

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: date from net compare to today issuing type mis-match

    yup. thanks again.

+ 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] Compare strings for match in separate worksheet and return nearest future date
    By kungfood in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2012, 05:19 PM
  2. [SOLVED] Compare with Date TODAY function, and have resulted in year to DateDiff Via VBA
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-07-2012, 01:18 PM
  3. Replies: 1
    Last Post: 08-23-2011, 12:06 PM
  4. Replies: 6
    Last Post: 08-08-2011, 08:32 AM
  5. How to compare today's date to a cell on VBA?
    By Sivangen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2006, 07:30 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