+ Reply to Thread
Results 1 to 3 of 3

Concatenate values

  1. #1
    Dan
    Guest

    Concatenate values

    Trying to concatenate data that is imported in a file but having a problem.

    ..Offset(0, 2).Value = Right("0000000" & myID & "h", 4)

    Data Want Get
    2C0 2C0h 2C0h
    402 402h 402h
    0 000h 0 h - two spaces between 0 and h
    14 0014h 14 h - one space b/w 14 and h
    2 0002h 2 h - two spaces between 2 and h

    Second problem is some of the data that is imported is "00" and I want to
    keep this
    format but when imported the "00" becomes "0".

    Any suggestions?

    Thanks

  2. #2
    davy_gravy
    Guest

    Re: Concatenate values

    Dan,

    try this:

    Sub dan()

    ActiveCell.Offset(0, 2).Value = Format(ActiveCell.Value, "000") & "h"
    End Sub

    Maybe that will get you started in the right direction.

    Regards,

    Dave

    Dan wrote:
    > Trying to concatenate data that is imported in a file but having a problem.
    >
    > .Offset(0, 2).Value = Right("0000000" & myID & "h", 4)
    >
    > Data Want Get
    > 2C0 2C0h 2C0h
    > 402 402h 402h
    > 0 000h 0 h - two spaces between 0 and h
    > 14 0014h 14 h - one space b/w 14 and h
    > 2 0002h 2 h - two spaces between 2 and h
    >
    > Second problem is some of the data that is imported is "00" and I want to
    > keep this
    > format but when imported the "00" becomes "0".
    >
    > Any suggestions?
    >
    > Thanks



  3. #3
    Dan
    Guest

    Re: Concatenate values

    Actually your statement about Format trigger a solution.

    ..Offset(0, 2).Value = Right("'000" & Trim(myID) & "h", 4)

    Realized there was possibly spaces during import that I could format out
    with Trim. This corrected the problem.

    Thanks

    "davy_gravy" wrote:

    > Dan,
    >
    > try this:
    >
    > Sub dan()
    >
    > ActiveCell.Offset(0, 2).Value = Format(ActiveCell.Value, "000") & "h"
    > End Sub
    >
    > Maybe that will get you started in the right direction.
    >
    > Regards,
    >
    > Dave
    >
    > Dan wrote:
    > > Trying to concatenate data that is imported in a file but having a problem.
    > >
    > > .Offset(0, 2).Value = Right("0000000" & myID & "h", 4)
    > >
    > > Data Want Get
    > > 2C0 2C0h 2C0h
    > > 402 402h 402h
    > > 0 000h 0 h - two spaces between 0 and h
    > > 14 0014h 14 h - one space b/w 14 and h
    > > 2 0002h 2 h - two spaces between 2 and h
    > >
    > > Second problem is some of the data that is imported is "00" and I want to
    > > keep this
    > > format but when imported the "00" becomes "0".
    > >
    > > Any suggestions?
    > >
    > > Thanks

    >
    >


+ 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