+ Reply to Thread
Results 1 to 12 of 12

Help removing the is numeric null value from code

Hybrid View

  1. #1
    Registered User
    Join Date
    08-14-2013
    Location
    Kentucky, United States
    MS-Off Ver
    03,07,10
    Posts
    61

    Help removing the is numeric null value from code

    I have the following code I am trying to remove the limiter that blocks the file from reporting if alpha but I need the code to still skip the first 3 rows of my excel form and NOT output the data from the first three rows to the .txt file. Is this possible?

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
        Const DELIMITER As String = "|"
        
        Dim varCol As Variant
        Dim strOutput As String
        Dim strTemp As String
        Dim i As Long
        
        For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
            If IsNumeric(Cells(i, "A").Value) And Len(Cells(i, "A").Value) > 0 Then
                strTemp = vbNullString
                For Each varCol In Array("A", "C", "E", "L", "Q", "S", "X", "Z", "AC", "AE", "AG")
                    Select Case (InStr(Cells(i, varCol).Text, "|") > 0)
                        Case True:  strTemp = strTemp & DELIMITER & """" & Cells(i, varCol).Text & """"
                        Case Else:  strTemp = strTemp & DELIMITER & Cells(i, varCol).Text
                    End Select
                Next varCol
                strTemp = Mid(strTemp, Len(DELIMITER) + 1)
                If Len(strOutput) = 0 Then strOutput = strTemp Else strOutput = strOutput & vbCrLf & strTemp
            End If
        Next i
        
        If Len(strOutput) > 0 Then
            Close #1
            Open "\\mdappc02\mtstats\STAGED\10_EOM\EOMStats.txt" For Output As #1
            Print #1, strOutput
            Close #1
        End If
    
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Help removing the is numeric null value from code

    Hi,

    Would this do the trick?
    For i = 4 To Cells(Rows.Count, "A").End(xlUp).Row
            If Len(Cells(i, "A").Value) > 0 Then
                strTemp = vbNullString
                For Each varCol In Array("A", "C", "E", "L", "Q", "S", "X", "Z", "AC", "AE", "AG")
                    Select Case (InStr(Cells(i, varCol).Text, "|") > 0)
                        Case True:  strTemp = strTemp & DELIMITER & """" & Cells(i, varCol).Text & """"
                        Case Else:  strTemp = strTemp & DELIMITER & Cells(i, varCol).Text
                    End Select
                Next varCol
                strTemp = Mid(strTemp, Len(DELIMITER) + 1)
                If Len(strOutput) = 0 Then strOutput = strTemp Else strOutput = strOutput & vbCrLf & strTemp
            End If
        Next i
    ???

    Hope this helps

  3. #3
    Registered User
    Join Date
    08-14-2013
    Location
    Kentucky, United States
    MS-Off Ver
    03,07,10
    Posts
    61

    Re: Help removing the is numeric null value from code

    I can not upload it but I can email it to you. if you would like to email me at lesleyengwer.le@gmail.com I can send it.

  4. #4
    Registered User
    Join Date
    08-14-2013
    Location
    Kentucky, United States
    MS-Off Ver
    03,07,10
    Posts
    61

    Re: Help removing the is numeric null value from code


  5. #5
    Registered User
    Join Date
    08-14-2013
    Location
    Kentucky, United States
    MS-Off Ver
    03,07,10
    Posts
    61

    Re: Help removing the is numeric null value from code

    lol... I did. the output was as such:

    4503|*|FS||||||||
    4576||GP||||||||
    4537||GQ||||||||
    4539||GR||||||||
    4548||GS||||||||
    4549||GT||||||||
    4543||GU||||||||
    7543||YZ||||DO NOT RUN|DO NOT RUN|DO NOT RUN|DO NOT RUN|
    4823||LM||||||||
    4825||OG||||||||
    4824||SG||||||||
    Number of sites with BIE: ||||||||||
    # of sites closed w/errors: ||||||||||
    # sites G/L file resent: ||||||||||
    # of sites closed late: ||||||||||
    * M/S/C - Managed/Sold/Closed Facilities; not included in YTD stats||||||||||
    * Late: Meditech Close is set @ 5pm EDT. Late close is determined by the MT Close End date/time.||||||||||
    rev 01/05/12||||||||||

    The numbers of the pipe delimiter are correct however if you see the "Number of sites with BIE: |||||||||| " this line and everything below needs to be removed.
    There is an EOF statment within the workbook that I am going to be putting the code into Please see below The EOF is where the Export needs to stop. :

    4549 W Tri-City
    4543 W Seattle First Hill
    7543 W Seattle First Hill SAU
    4823 W La Mirada
    4825 W Santa Ana
    4824 W San Gabriel

    EOF
    Number of sites with BIE:
    # of sites closed w/errors:
    # sites G/L file resent:
    # of sites closed late:

  6. #6
    Registered User
    Join Date
    08-14-2013
    Location
    Kentucky, United States
    MS-Off Ver
    03,07,10
    Posts
    61

    Re: Help removing the is numeric null value from code

    Hello,

    This helps however I needed the Export data to end when " EOF " is found in Column A. There is data after the accronym " EOF" that i can not have on the .txt file. there will be numbers added in the future and EOF should not be seen on the .txt file.

    I hope this makes sense. Thank you so much for your help!

  7. #7
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Help removing the is numeric null value from code

    Or try this
    For i = 4 To Cells(Rows.Count, "A").End(xlUp).Row
            If Len(Cells(i, "A").Value) > 0 And Cells(i,"A").Value <> "EOF" Then
                strTemp = vbNullString
                For Each varCol In Array("A", "C", "E", "L", "Q", "S", "X", "Z", "AC", "AE", "AG")
                    Select Case (InStr(Cells(i, varCol).Text, "|") > 0)
                        Case True:  strTemp = strTemp & DELIMITER & """" & Cells(i, varCol).Text & """"
                        Case Else:  strTemp = strTemp & DELIMITER & Cells(i, varCol).Text
                    End Select
                Next varCol
                strTemp = Mid(strTemp, Len(DELIMITER) + 1)
                If Len(strOutput) = 0 Then strOutput = strTemp Else strOutput = strOutput & vbCrLf & strTemp
            ElseIf Cells(i, "A").Value = "EOF" Then
                Exit For
            End If
        Next i
    Maybe this will be a simple solution
    Last edited by ajryan88; 08-29-2013 at 10:55 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Help removing the is numeric null value from code

    No worries.

    Can you please upload your workbook so that I can take a look at and debug the code in context?

    Thanks

  9. #9
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Help removing the is numeric null value from code

    Perhaps try my updated suggestion first, as your workbook obviously contains sensitive data which I don't want to see just as much as you probably don't want me to see it :P

  10. #10
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Help removing the is numeric null value from code

    Sorry, I edited my last post but I mustn't have been quick enough.

    I know that would happen, so I changed the code that I suggested, and it should now fix the problem. Please try again

  11. #11
    Registered User
    Join Date
    08-14-2013
    Location
    Kentucky, United States
    MS-Off Ver
    03,07,10
    Posts
    61

    Re: Help removing the is numeric null value from code

    That worked perfectly you are amazing! THANK YOU!!!!!!!!!!!!!!

  12. #12
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Help removing the is numeric null value from code

    No problems! Glad I could help

    Please don't forget to mark this thread as solved and please click on the * next to my post to say thanks

    Have a great day!

+ 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] Removing Null String from a range
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2012, 01:57 PM
  2. Removing null lines from a sheet
    By komet12 in forum Excel General
    Replies: 1
    Last Post: 09-01-2011, 08:23 AM
  3. Removing double quote on null column
    By lilvi3tboix1 in forum Excel General
    Replies: 5
    Last Post: 01-11-2011, 09:32 AM
  4. Code to replace null and not null strings
    By tigertim71 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2008, 05:07 PM
  5. Removing Non-Numeric Characters
    By GlenS in forum Excel General
    Replies: 5
    Last Post: 10-12-2005, 06:05 AM

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