Solved

Excel Macro Question

Posted on 2014-11-24
7
70 Views
Last Modified: 2014-12-09
Good day everyone i was wondering if I could get some assistance. I am working with excel and have some cells in a column with the values below. Of this one column  EX: C1 in each row could vary as far as the number of delimited items. If I could I would like a macro that will append to the last item in this column C1-105 and I could be prompted or manually type in a entry to append to this column, thanks


C1-C105
one group; doe, john; jane, mary; two group
onegroup;another person; onemoreperson; evenmoreperson
ditto
ditto
ditto
ditto
0
Comment
Question by:techdrive
7 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40462134
Don't know what you want - please explain more clearly.
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40462493
Assuming you have a list of names in column A, the following in C2 will concatenate the names as they increase:

=C1&"; "A2

Copy down as required and then copy further as entries are added to column A.

Thanks
Rob H
0
 

Author Comment

by:techdrive
ID: 40462770
C--Users-388822-Pictures-account-before-C--Users-388822-Pictures-account-need-th
I will try to explain a different way. The first file is before what I have "before-presentlywhat I have.JPG". I presently have a column full of data seperated by a semi-colon. I wanted to automate adding another name and appending this after the last entry in the column. I have noted what the finished file should look like with the name "need-the-macro-to-do.JPG". Please let me know if this provides some clarity.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40463167
Sub AddNewgroup
Introw = 1
Do until cells(introw, 3) =""
  cells(introw, 3) = cells(introw, 3) & ";newgroup"
  introw = introw + 1
Loop
End sub
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40463171
Please make sure that you have saved your spreadsheet beforehand, as the changes are not undo able.

The word newgroup should be Newgroup in the code above.
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40463268
In B2 enter value required to be added to values in C. Then in D put formula:

=C2&$B$2&";"

Copy down as required. Then copy and paste values into C.


Repeat with new value in B2 as required.
0
 
LVL 5

Expert Comment

by:Hakan Yılmaz
ID: 40472277
Select the cells you want to add group to and run, addgrouptoselectedcells
Select the cells you want to remove group from and run, removegroupfromselectedcells


Option Explicit

Const groupdelimiter As String = ";"

Sub addgrouptoselectedcells()
    Dim newgroupname As String
    newgroupname = InputBox("New group name", "Append new group", "New Group")
    addgroup Selection, newgroupname
End Sub

Sub removegroupfromselectedcells()
    Dim groupname As String
    groupname = InputBox("Group name", "Remove group", "Group name")
    removegroup Selection, groupname
End Sub

Sub addgroup(ByRef groupstoappend As Range, ByVal newgroupname As String)
    Dim itercell As Range
    For Each itercell In groupstoappend
        itercell.Value = itercell.Value2 & IIf(Len(itercell.Value2) > 0, groupdelimiter, "") & newgroupname
    Next itercell
End Sub

Sub removegroup(ByRef groupstoremovefrom As Range, ByVal groupname As String)
    Dim itercell As Range
    For Each itercell In groupstoremovefrom
        itercell.Value = Replace(itercell.Value2, groupname & groupdelimiter, "")
        itercell.Value = Replace(itercell.Value2, groupdelimiter & groupname, "")
        itercell.Value = Replace(itercell.Value2, groupname, "")
        itercell.Value = Replace(itercell.Value2, groupdelimiter & groupdelimiter, "")
    Next itercell
End Sub

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question