+ Reply to Thread
Results 1 to 2 of 2

Thread: Copy-and-paste issues with period in column label

  1. #1
    Registered User
    Join Date
    06-14-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Copy-and-paste issues with period in column label

    Hi,

    I have a VBA function that simply accepts an Excel file with simple column & row data as input and pastes the result into another.

    The problem is that, if one of my column names contains a period, the period (.) in the name gets converted to a pound sign (#). For example, if I abbreviate AMOUNT to AMT. with a trailing period, the result after the paste gives AMT# (trailing pound sign) .

    I am using the following VBA subroutine in order to parse the table and paste the result into my final Excel sheet:

    ' *** Parse the table and write result record set to Excel sheet
    Do Until objRecordset.EOF
    ActiveSheet.Cells.ClearContents
    SheetName = ActiveSheet.Name
    Sheets(SheetName).Range("A2").CopyFromRecordset objRecordset
    For n = 0 To (objRecordset.Fields.Count - 1)
    iCol = iCol + 1
    Sheets(SheetName).Cells(1, iCol).Value = objRecordset.Fields(n).Name
    iSheetCount = ThisWorkbook.Sheets(SheetName).UsedRange.Rows.Count
    Next n
    Loop


    The following line from the above subroutine is responsible for the final paste of the column name:

    Sheets(SheetName).Cells(1, iCol).Value = objRecordset.Fields(n).Name


    Any help would be greatly appreciated in order to get around this issue.

    Kind regards,
    Shawn

  2. #2
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: Copy-and-paste issues with period in column label

    Shawn, please edit your post and wrap your code within [CODE] ... [/CODE] tags, per the forum rules (link in my signature below). Once you have done this please send me a PM and I'll remove this request.

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0