+ Reply to Thread
Results 1 to 10 of 10

help to pickout first lettet in one column and replace contents in other column with esult

  1. #1
    Registered User
    Join Date
    01-31-2015
    Location
    perth, australia
    MS-Off Ver
    2010
    Posts
    16

    help to pickout first lettet in one column and replace contents in other column with esult

    I need to create a mcaro that will search through a large column of surnames(Col2) that already sorted A-Z then every time it finds the first letter of the alpha it'll replace the adjacent col1 with the first letter like if the col2,
    I know the simple part which is =LEFT(B3,1) but the search part using if and isnot I am not really sure about how to start get something similar to the following resultsorry I don't know how to enter columns in this post)

    Col1, . ,Col2
    ID, , Name

    12220001 , ,adamsS
    44522522 , , jones
    32511321 , ,macabe
    645464 , , macdemo
    2654654, , macmonagle
    15651 , ,mcginty
    65464 , ,smith
    54566 , ,Willison
    654654 , ,willlaimson

    A, , adamsS
    J, , jones
    M, , macabe
    645464, , macdemo
    2654654, , macmonagle
    15651, , mcginty
    S, , smith
    W, , Willison
    654654, , willlaimson



    any help would be helpful
    thanks in advance

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: help to pickout first lettet in one column and replace contents in other column with e

    Try something like this...
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: help to pickout first lettet in one column and replace contents in other column with e

    Different method...
    No need to be sorted, no loop
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-31-2015
    Location
    perth, australia
    MS-Off Ver
    2010
    Posts
    16

    Re: help to pickout first lettet in one column and replace contents in other column with e

    many thanks

  5. #5
    Registered User
    Join Date
    01-31-2015
    Location
    perth, australia
    MS-Off Ver
    2010
    Posts
    16

    Re: help to pickout first lettet in one column and replace contents in other column with e

    loved the code, changed a little to add right side cell:wish i new what was going on though so i could add bold to this as well just for the changed cells only:

    Sub test()
    With Range("b1", Range("b" & Rows.Count).End(xlUp))

    .Offset(, -1).Value = Evaluate("if(countif(offset(" & .Address & ",,,row(1:" & .Rows.Count & _
    ")),left(" & .Address & ",1)&""*"")=1,upper(left(" & .Address & ",1))," & .Offset(, -1).Address & ")")
    Application.CutCopyMode = False
    End With
    Columns("A:A").Select
    Application.CutCopyMode = False
    With Selection
    .HorizontalAlignment = xlRight
    End With
    End Sub

  6. #6
    Registered User
    Join Date
    01-31-2015
    Location
    perth, australia
    MS-Off Ver
    2010
    Posts
    16

    Re: help to pickout first lettet in one column and replace contents in other column with e

    any ideas on how the above works or how to bold would be good ...thanks in advance

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: help to pickout first lettet in one column and replace contents in other column with e

    Try this for you data.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-31-2015
    Location
    perth, australia
    MS-Off Ver
    2010
    Posts
    16

    Re: help to pickout first lettet in one column and replace contents in other column with e

    Thanks, the code bolds just fine but it does the whole column, not just the changed cells like I would like.
    I guess .Font.Bold = True would need ot be inserted in the code somewhere else as the changes were being made, I ttried a few different places, but had no luck as I don't know how the code works to well, many thanks for your effort though

  9. #9
    Registered User
    Join Date
    01-31-2015
    Location
    perth, australia
    MS-Off Ver
    2010
    Posts
    16

    Re: help to pickout first lettet in one column and replace contents in other column with e

    anybody have any suggestions on the bolding issue as above

  10. #10
    Registered User
    Join Date
    01-31-2015
    Location
    perth, australia
    MS-Off Ver
    2010
    Posts
    16

    Re: help to pickout first lettet in one column and replace contents in other column with e

    Quote Originally Posted by gint32 View Post
    Thanks, the code bolds just fine but it does the whole column, not just the changed cells like I would like.
    I guess .Font.Bold = True would need ot be inserted in the code somewhere else as the changes were being made, I ttried a few different places, but had no luck as I don't know how the code works to well, many thanks for your effort though
    Thanks, the code above does boldout just fine but it does the whole column, not just the changed cells like I would like I had asked.
    I guess .Font.Bold = True would need to be possibly inserted in the actual code part somewhere else right as the changes were being made, I tried to insert the command in a few different places, but I had no luck with this as I don't know how the VBA example above works well enough to ammend, many thanks for your effort though

+ 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: 3
    Last Post: 11-25-2014, 06:08 AM
  2. Replies: 5
    Last Post: 08-01-2014, 04:30 PM
  3. [SOLVED] Column O and Column P shall filled if there are contents in Column A before Close
    By wunderbartina in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-06-2014, 06:09 AM
  4. [SOLVED] Split One Column at Delimiter While Copying Contents of Second Column to Populate New Rows
    By medailSacrosanct in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-01-2012, 11:37 AM
  5. Formula/macro to edit cells in one column based on contents of a cell in another column
    By robbyvegas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-25-2012, 06:10 AM
  6. Replies: 2
    Last Post: 05-18-2012, 12:34 AM
  7. [SOLVED] How do I replace cell contents or add another column.
    By KELLIS in forum Excel General
    Replies: 6
    Last Post: 05-10-2012, 12:02 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