Excel Macro Question

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

one group; doe, john; jane, mary; two group
onegroup;another person; onemoreperson; evenmoreperson
Who is Participating?
Phillip BurtonConnect With a Mentor Director, Practice Manager and Computing ConsultantCommented:
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.
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
Don't know what you want - please explain more clearly.
Rob HensonFinance AnalystCommented:
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.

Rob H
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

techdriveAuthor Commented:
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.
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
Sub AddNewgroup
Introw = 1
Do until cells(introw, 3) =""
  cells(introw, 3) = cells(introw, 3) & ";newgroup"
  introw = introw + 1
End sub
Rob HensonFinance AnalystCommented:
In B2 enter value required to be added to values in C. Then in D put formula:


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

Repeat with new value in B2 as required.
Hakan YılmazTechnical Office MEP EngineerCommented:
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

All Courses

From novice to tech pro — start learning today.