Results 1 to 5 of 5

Thread: [Resolved]Convert Substitute to VBA Code

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    74

    [Resolved]Convert Substitute to VBA Code

    What would this be in VBA code?


    If Len(Trim(rngGridCell)) - Len(Substitute(rngGridCell, " ", "")) + 1 < 28 Then

    When I try to run it like that it tells me "sub or Function not defined"

    Thanks!
    Last edited by gtg689a; May 4th, 2006 at 12:23 PM.

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Convert Substitute to VBA Code

    you need the REPLACE function.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    74

    Re: Convert Substitute to VBA Code

    Idon't think that will work, I want to first count the length of the charachters in the cell, then i want to remove all of the blank spaces and subtract that by the original length.

    that would give me how many names were in the cell.
    I need to be able to replace specific instances (ie. " " with ""), I don't think replace lets me do that?

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Convert Substitute to VBA Code

    Yes, it will let you do that. Here's an example.

    VB Code:
    1. Sub SampleReplace()
    2. Dim sInput As String
    3. Dim sOutput As String
    4.  
    5.     sInput = "This is a Test"
    6.    
    7.     sOutput = Replace(sInput, " ", "")
    8.    
    9.     MsgBox sOutput
    10. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    74

    Re: Convert Substitute to VBA Code

    Eureka!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width