+ Reply to Thread
Results 1 to 2 of 2

Excel macro converting values to text

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    12

    Excel macro converting values to text

    Hi, I am not an excel expert but i was able to get this macro to work with a couple of minor problems.
    a) how do i remove the last comma from line 6 (40 instead of 40,)
    b) Can i remove the last comma and "-" from any other line (line 3 for example)
    Thank you for your time

    1,2,3,4,5,6,7, -
    8,9,10,11,12,13,14, -
    15,16,17,18,19,20,21, -
    22,23,24,25,26,27,28, -
    29,30,31,32,33,34,35, -
    36,37,38,39,40,


    Sub Test()
    Dim a As String, b, c, d As Long
    a = "'" & CStr(Cells(40, 2).Value) & ","
    b = 3
    c = 6
    d = 1
    While Not IsEmpty(Cells(40, b))
    a = a & CStr(Cells(40, b).Value) & ","
    b = b + 1
    d = d + 1
    If d >= 7 Then
    a = a & " -"
    Cells(c, 53).Value = a
    c = c + 1
    a = ""
    d = 0
    End If
    If c > 10 Then
    Cells(c, 53).Value = a
    End If
    Wend
    End Sub

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Excel macro converting values to text

    Maybe:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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