+ Reply to Thread
Results 1 to 3 of 3

VBA codes running on Column C. I want it to run not only on column C but from C to L.

  1. #1
    Registered User
    Join Date
    05-26-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    2

    Red face VBA codes running on Column C. I want it to run not only on column C but from C to L.

    Hi everyone, appreciate your valuable inputs. I have the following VBA codes which is currently running on Column C. I want it to run not only on column C but also from C to L.

    Sub RemoveNonDigitsC()
    Dim X As Long, Z As Long, LastRow As Long, CellVal As String
    Const StartRow As Long = 2
    Const DataColumn As String = "C"
    Application.ScreenUpdating = False
    LastRow = Cells(Rows.Count, DataColumn).End(xlUp).Row
    For X = StartRow To LastRow
    CellVal = Cells(X, DataColumn)
    For Z = 1 To Len(CellVal)
    If Mid(CellVal, Z, 1) Like "[!-,0.00-9]" Then Mid(CellVal, Z, 1) = " "
    Next
    With Cells(X, DataColumn)
    .NumberFormat = "#,0.00"
    .Value = Replace(CellVal, " ", "")
    End With
    Next
    Application.ScreenUpdating = True
    End Sub



    Thanks in advance~!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,041

    Re: VBA codes running on Column C. I want it to run not only on column C but from C to L.

    Does this work (untested)?

    Please Login or Register  to view this content.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    05-26-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    2

    Re: VBA codes running on Column C. I want it to run not only on column C but from C to L.

    Special-K,

    Thank you so much. Your vba code inputs works perfectly.

+ 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. Replies: 6
    Last Post: 11-28-2006, 01:08 PM
  2. Replies: 3
    Last Post: 08-01-2006, 08:15 PM
  3. Replies: 1
    Last Post: 05-19-2005, 05:06 PM
  4. [SOLVED] Only Allowing Certain Codes In Column
    By Buttercup in forum Excel General
    Replies: 2
    Last Post: 01-06-2005, 06:06 PM
  5. [SOLVED] Set column to only allow certain codes???
    By Buttercup in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-06-2005, 05:06 PM

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