I have Excel worksheet that contains a columns with text. Sometimes there is only one cell in the row with text (say, in A2), sometimes there are two two cells (say, A3 “From the beginning”, B3 “to the End”), sometimes three cells (A4 “From”, B4 “the beginning”, C4 “to the End”). Of course, the text is different from cell to cell. I need to write a macro that merge text in one cell (A4 “From the beginning to the End”, B4 and C4 blank) and do it automatically through all column (A). Any help will be greatly appreciated.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Macro to merge text (Any)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Macro to merge text (Any)
- This topic has 7 replies, 4 voices, and was last updated 22 years, 2 months ago.
Viewing 1 reply threadAuthorReplies-
H. Legare Coleman
AskWoody PlusApril 8, 2003 at 1:01 pm #667035 -
WSkaplinb
AskWoody LoungerApril 8, 2003 at 3:03 pm #667064I want to do it in all non-empty rows: from 2 to 1275, or 1836, or whatever until the cell in column A will be empty. If there is nothing in column B, there is also nothing in column C. There is nothing in column D etc. (The worksheet was created from the text file, last column of which, converted into column A in the worksheet, contained text sometimes with hard returns to wrap it. Text in any cell can start either with capital or lowercase letter. There were too many entries to remove hard returns manually. But I need all text to be in one cell. Blank spaces at the end are not importamt.)
-
WSHansV
AskWoody LoungerApril 8, 2003 at 3:45 pm #667107Something like this?
Sub MergeABC()
Dim aRange As Range
Dim aCell As RangeOn Error GoTo Exit_Sub
Set aRange = Range(Range(“A2”), Range(“A65536”).End(xlUp))
For Each aCell In aRange
If aCell.Offset(0, 1) “” Then
aCell = aCell & ” ” & aCell.Offset(0, 1)
If aCell.Offset(0, 2) “” Then
aCell = aCell & ” ” & aCell.Offset(0, 2)
End If
End If
NextaRange.Offset(0, 1).Clear
aRange.Offset(0, 2).ClearExit_Sub:
Set aCell = Nothing
Set aRange = Nothing
End Sub -
WSServando
AskWoody LoungerApril 8, 2003 at 4:03 pm #667114And what about this:
Sub MergeABC()
Dim aRange As Range
Dim aCell As RangeOn Error GoTo Exit_Sub
Set aRange = Range(Range(“A2”), Range(“A65536″).End(xlUp))
For Each aCell In aRange
aCell = Trim(aCell & ” ” & aCell.Offset(0, 1) & ” ” & aCell.Offset(0, 2))
NextaRange.Offset(0, 1).Clear
aRange.Offset(0, 2).ClearExit_Sub:
Set aCell = Nothing
Set aRange = Nothing
End Sub
-
-
-
-
WSHansV
AskWoody LoungerApril 8, 2003 at 1:19 pm #667033
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
5 hours, 26 minutes ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
1 hour, 10 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
4 hours ago -
Discover the Best AI Tools for Everything
by
Alex5723
4 hours, 9 minutes ago -
Edge Seems To Be Gaining Weight
by
bbearren
4 hours, 52 minutes ago -
Rufus is available from the MSFT Store
by
PL1
2 hours, 21 minutes ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
1 day, 5 hours ago -
KB5061768 update for Intel vPro processor
by
drmark
11 hours, 37 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
7 hours, 48 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
1 day ago -
Office gets current release
by
Susan Bradley
1 day, 3 hours ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
2 days, 17 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
2 days, 2 hours ago -
Stop the OneDrive defaults
by
CWBillow
2 days, 18 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
3 days, 4 hours ago -
X Suspends Encrypted DMs
by
Alex5723
3 days, 6 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
3 days, 6 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
3 days, 7 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
3 days, 8 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
2 days, 20 hours ago -
Enabling Secureboot
by
ITguy
3 days, 3 hours ago -
Windows hosting exposes additional bugs
by
Susan Bradley
3 days, 16 hours ago -
No more rounded corners??
by
CWBillow
3 days, 11 hours ago -
Android 15 and IPV6
by
Win7and10
3 days, 1 hour ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
4 days, 4 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
4 days, 7 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
4 days, 1 hour ago -
Windows Update orchestration platform to update all software
by
Alex5723
4 days, 14 hours ago -
May preview updates
by
Susan Bradley
4 days, 1 hour ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
3 days, 17 hours ago
Recent blog posts
Key Links
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.