+ Reply to Thread
Results 1 to 12 of 12

Can anyone offer a solution ?

  1. #1
    Registered User
    Join Date
    04-13-2006
    Posts
    6

    Can anyone offer a solution ?

    Hello everyone,

    Can anybody offer a solution to my problem:

    I have a list of 4 digit numbers in column A (I need to retain leading zeros for numbers < 1000)
    I have 19 cells in column B containg alpha-numeric data.
    I want Column C to contain a copy of the alpha-numeric data preceded by the 4 digit number in column A.
    I'm after a Macro, I think ! or some functions to make life easier as Column A has 440 entries !

    It doesn't go down on paper as easy as it looks so I've attached an example:

    Many thanks in advance for any help one this one.

    The .jpg is unreadable - I'll try something else - - -
    Attached Images Attached Images
    Last edited by pc300d; 04-13-2006 at 05:07 PM.

  2. #2
    Registered User
    Join Date
    04-13-2006
    Posts
    6

    Here's a better example

    The JPEG is a bit naff, here's a Word doc that's better.

    Regards
    Attached Files Attached Files

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451
    Try this:

    =IF(A1<1000,CHOOSE(LEN(A1),"000","00","0")&A1&B1,A1&B1)

    and copy down

  4. #4
    Registered User
    Join Date
    04-13-2006
    Posts
    6
    Hi Cutter, thanks for the reply.

    It "sort of" works but is not what I'm after.

    Firstly Column A has numbers above 1000 (up to 4000) I just mentioned 1000 in the first post as I need to keep the leading zeros on all numbers less than a thousand.

    Secondly, for each cell in column A I need 19 cells in column C.

    In the example; cell A1 = 0001, I need 0001 placed in cells C1 to C19 but with the info in cells B1 to B19 placed after it.
    So column C would look like
    C1 0001HS01
    C2 0001HS02
    C3 0001MIC
    C4 0001SP01
    down to
    C19 0001SP16
    Then C20 would start with the second cell in column A (ie 0002)
    C20 0002HS01
    C21 0002HS02
    etc. etc.

    I've dabbled with the IF command but I cannot work out exactly what your suggestion is doing. I does work for numbers less than 1000 but it doesn't address the 19 entries in column B per 1 entry in column A.

    'Hope that made some sort of sense !

    Thanks and regards

  5. #5
    Sandy Mann
    Guest

    Re: Can anyone offer a solution ?

    Shamelessly stealing an idea from Bob Philips:

    =RIGHT("0000"&A1,4)&B1

    --
    HTH

    Sandy
    In Perth, the ancient capital of Scotland

    [email protected]
    [email protected] with @tiscali.co.uk


    "pc300d" <[email protected]> wrote in
    message news:[email protected]...
    >
    > The JPEG is a bit naff, here's a Word doc that's better.
    >
    > Regards
    >
    >
    > +-------------------------------------------------------------------+
    > |Filename: Excel Help.doc |
    > |Download: http://www.excelforum.com/attachment.php?postid=4628 |
    > +-------------------------------------------------------------------+
    >
    > --
    > pc300d
    > ------------------------------------------------------------------------
    > pc300d's Profile:
    > http://www.excelforum.com/member.php...o&userid=33474
    > View this thread: http://www.excelforum.com/showthread...hreadid=532785
    >




  6. #6
    Registered User
    Join Date
    04-13-2006
    Posts
    6
    Hi Sandy,

    That works better in that it works on numbers higher that 1000.

    It still doesn't address the fact that I don't need A1 added to B1 then A2 added to B2.

    What I need is:
    A1 added to B1, A1 added to B2, A1 added to B3........A1 added to B19.

    Then A2 added to B1, A2 added to B2, A2 added to B3.......A2 added to B19.

    Then A3 added to B1, A3 added to B2, A3 added to B3.......A3 added to B19.

    With your formula I could manipulate column A so that it had the first 19 cells equal to A1, the next 19 cells equal to what was in A2 and then copy cells B1 to B19 down to match column A. Finally copy your formula down coumn C to produce the figures I want but that would be so much work as there are 4000 numbers in column A!

    I'm not too sure a single cell formula is what I need maybe I need some sort of macro but it looks to me like it would be way beyond my expertise to come up with one (at least I've found the smileys )

    Thanks and regards

  7. #7
    Sandy Mann
    Guest

    Re: Can anyone offer a solution ?

    In that case I think that you are right in that you will need a Macro. Try
    something like:

    Sub Trial()
    Dim x As Long
    Dim y As Long
    Dim z As Long
    Dim Acol As Long
    Dim Bcol As Long

    Application.ScreenUpdating = False

    Acol = Cells(1, 1).End(xlDown).Row
    Bcol = Cells(1, 2).End(xlDown).Row

    For x = 1 To Acol
    For y = 1 To Bcol
    Cells(x * Bcol - Bcol + y, 3).Value = _
    Right("0000" & Cells(1, 1).Value, 4) _
    & Cells(y, 2).Value
    Next y
    Next x

    Application.ScreenUpdating = True

    End Sub


    --
    HTH

    Sandy
    In Perth, the ancient capital of Scotland

    [email protected]
    [email protected] with @tiscali.co.uk


    "pc300d" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi Sandy,
    >
    > That works better in that it works on numbers higher that 1000.
    >
    > It still doesn't address the fact that I don't need A1 added to B1 then
    > A2 added to B2.
    >
    > What I need is:
    > A1 added to B1, A1 added to B2, A1 added to B3........A1 added
    > to B19.
    >
    > Then A2 added to B1, A2 added to B2, A2 added to B3.......A2 added to
    > B19.
    >
    > Then A3 added to B1, A3 added to B2, A3 added to B3.......A3 added to
    > B19.
    >
    > With your formula I could manipulate column A so that it had the first
    > 19 cells equal to A1, the next 19 cells equal to what was in A2 and
    > then copy cells B1 to B19 down to match column A. Finally copy your
    > formula down coumn C to produce the figures I want but that would be so
    > much work as there are 4000 numbers in column A!
    >
    > I'm not too sure a single cell formula is what I need maybe
    > I need some sort of macro but it looks to me like it would be way
    > beyond my expertise to come up with one (at least I've found the
    > smileys )
    >
    > Thanks and regards
    >
    >
    > --
    > pc300d
    > ------------------------------------------------------------------------
    > pc300d's Profile:
    > http://www.excelforum.com/member.php...o&userid=33474
    > View this thread: http://www.excelforum.com/showthread...hreadid=532785
    >





  8. #8
    Registered User
    Join Date
    04-13-2006
    Posts
    6

    Thumbs up

    Thank you for your time Sandy, we're very nearly there !

    The macro is hard for me to understand, as I said before I'm fairly new to all this, so I don't know which "bit" needs tweaking.

    Once the macro is run the resulting column (column C) is "parsed" with the 19 cells in column B which is perfect, but the prefix is always cell A1.

    ie. as in my previous posts, column C has 0001 as the 1st 4 digits in every cell (all 9000 of 'em) so the macro isn't stepping down column A.

    Sorry to be pain but if this works it will save me an enormous amount of time in the future.


    UPDATE: Thanks for all your help, I posted the problem in another forum at the same time and I now have a solution, very similar to the one posted by Sandy ('hope that doesn't offend anyone !) Thanks again for your time & efforts.

    Regards & Happy Easter !!
    Last edited by pc300d; 04-14-2006 at 11:28 AM.

  9. #9
    slowhand
    Guest

    Re: Can anyone offer a solution ?


    try making the A1 cell absoute

    =RIGHT("0000"&$A$1,4)&B1


    --
    slowhand
    Posted from - http://www.officehelp.in


  10. #10
    Sandy Mann
    Guest

    Re: Can anyone offer a solution ?

    "pc300d" <[email protected]> wrote in
    message news:[email protected]...

    > Sorry to be pain


    You're not being a pain, it me that's being a pain - I changed the x
    variable to a 1 to run a test and forgot to change it back again before
    posting.

    change:
    Cells(x * Bcol - Bcol + y, 3).Value = _
    Right("0000" & Cells(1, 1).Value, 4) _
    & Cells(y, 2).Value

    to:
    Cells(x * Bcol - Bcol + y, 3).Value = _
    Right("0000" & Cells(x, 1).Value, 4) _
    & Cells(y, 2).Value

    and it should work as you want.

    --
    HTH

    Sandy
    In Perth, the ancient capital of Scotland

    [email protected]
    [email protected] with @tiscali.co.uk


    "pc300d" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Thank you for your time Sandy, we're very nearly there !
    >
    > The macro is hard for me to understand, as I said before I'm fairly new
    > to all this, so I don't know which "bit" needs tweaking.
    >
    > Once the macro is run the resulting column (column C) is "parsed" with
    > the 19 cells in column B which is perfect, but the prefix is always
    > cell A1.
    >
    > ie. as in my previous posts, column C has 0001 as the 1st 4 digits in
    > every cell (all 9000 of 'em) so the macro isn't stepping down column
    > A.
    >
    > Sorry to be pain but if this works it will save me an enormous amount
    > of time in the future.
    >
    > Many thanks
    >
    >
    > --
    > pc300d
    > ------------------------------------------------------------------------
    > pc300d's Profile:
    > http://www.excelforum.com/member.php...o&userid=33474
    > View this thread: http://www.excelforum.com/showthread...hreadid=532785
    >




  11. #11
    Anders Silven
    Guest

    Re: Can anyone offer a solution ?

    Hi,

    If I read you right, here is one way to do it with worksheet functions.

    Enter in column C and fill down:

    =RIGHT("0000"&INDEX(A:A,INT((ROW()-1)/19)+1),4)&INDEX(B:B,MOD(ROW()-1,19)+1)

    (Formula borrowed from Bob and Sandy.)

    HTH
    Anders Silven

    "pc300d" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi Cutter, thanks for the reply.
    >
    > It "sort of" works but is not what I'm after.
    >
    > Firstly Column A has numbers above 1000 (up to 4000) I just mentioned
    > 1000 in the first post as I need to keep the leading zeros on all
    > numbers less than a thousand.
    >
    > Secondly, for each cell in column A I need 19 cells in column C.
    >
    > In the example; cell A1 = 0001, I need 0001 placed in cells C1 to C19
    > but with the info in cells B1 to B19 placed after it.
    > So column C would look like
    > C1 *0001*HS01
    > C2 *0001*HS02
    > C3 *0001*MIC
    > C4 *0001*SP01
    > down to
    > C19 *0001*SP16
    > Then C20 would start with the second cell in column A (ie *0002*)
    > C20 *0002*HS01
    > C21 *0002*HS02
    > etc. etc.
    >
    > I've dabbled with the IF command but I cannot work out exactly what
    > your suggestion is doing. I does work for numbers less than 1000 but it
    > doesn't address the 19 entries in column B per 1 entry in column A.
    >
    > 'Hope that made some sort of sense !
    >
    > Thanks and regards
    >
    >
    > --
    > pc300d
    > ------------------------------------------------------------------------
    > pc300d's Profile:
    > http://www.excelforum.com/member.php...o&userid=33474
    > View this thread: http://www.excelforum.com/showthread...hreadid=532785
    >



  12. #12
    Registered User
    Join Date
    04-13-2006
    Posts
    6

    Thumbs up

    Yep ! that works as well, thanks Anders

    With my limited knowledge of Excel this will be slightly easier for me to carry around and explain to my colleagues it's use.

    Many thanks again to all those who helped.

    PC300D

+ 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