+ Reply to Thread
Results 1 to 2 of 2

Concatenate Text Strings Across Worksheets HELP

  1. #1
    Registered User
    Join Date
    08-12-2015
    Location
    MY OWN LITTLE WORLD
    MS-Off Ver
    2010
    Posts
    1

    Concatenate Text Strings Across Worksheets HELP

    This seems like it should be easy, but has become quite a pain!

    I have 20 worksheets (H1-H20), which are used by auditors to review patient records. Compliance is tracked on a simple binary system 1=met, 2=not met. The total met/not met are combined on a master sheet (HCS TOTALS), which is identical to each H1-H20 worksheet. That was the easy part.

    However, there are several merged cells where the auditor is able to make comments. I have used the following formula to concatenate all comments to the corresponding comment cell on HCS TOTALS:

    =CONCATENATE('H1'!AJ15:AR17,CHAR(10),CHAR(10),'H2'!AJ15:AR17,CHAR(10),CHAR(10),'H3'!AJ15:AR17,CHAR(10),CHAR(10),'H4'!AJ15:AR17,CHAR(10),CHAR(10),'H5'!AJ15:AR17,CHAR(10),CHAR(10), 'H6'!AJ15:AR17,CHAR(10),CHAR(10),'H7'!AJ15:AR17,CHAR(10),CHAR(10),'H8'!AJ15:AR17,CHAR(10),CHAR(10),'H9'!AJ15:AR17,CHAR(10),CHAR(10),'H10'!AJ15:AR17,CHAR(10),CHAR(10), 'H11'!AJ15:AR17,CHAR(10),CHAR(10),'H12'!AJ15:AR17,CHAR(10),CHAR(10),'H13'!AJ15:AR17,CHAR(10),CHAR(10),'H14'!AJ15:AR17,CHAR(10),CHAR(10),'H15'!AJ15:AR17,CHAR(10),CHAR(10), 'H16'!AJ15:AR17,CHAR(10),CHAR(10),'H17'!AJ15:AR17,CHAR(10),CHAR(10),'H18'!AJ15:AR17,CHAR(10),CHAR(10),'H19'!AJ15:AR17,CHAR(10),CHAR(10),'H20'!AJ15:AR17,CHAR(10))

    The formula works, but there are two problems: (1) the formula does not skip blank cells and (2) the merge cell does not auto-resize to fit the contents.

    I am using the following macro to manually resize the comment section:

    Sub AutoFitMergedCellRowHeight()
    Dim MergedHeight As Single
    Dim MergedWidth As Single
    Dim PossNewRowHeight As Single
    Dim lngRowCount As Long
    Dim lngColCount As Long
    Dim i As Long
    Dim ActiveCellWidth As Single
    If ActiveCell.MergeCells Then
    With ActiveCell.MergeArea
    If .WrapText = True Then
    lngRowCount = .Rows.Count
    lngColCount = .Columns.Count
    Application.ScreenUpdating = False
    MergedHeight = Selection.Height
    For i = 1 To lngColCount
    MergedWidth = .Cells(1, i).ColumnWidth + 1 + MergedWidth
    Next i
    ActiveCellWidth = ActiveCell.ColumnWidth
    .MergeCells = False
    .Cells(1).RowHeight = MergedHeight
    .Cells(1).ColumnWidth = MergedWidth
    .EntireRow.AutoFit
    PossNewRowHeight = .Cells(1).RowHeight
    .MergeCells = True
    .Cells(1).ColumnWidth = ActiveCellWidth
    For i = 1 To lngRowCount
    .Cells(i, 1).RowHeight = PossNewRowHeight / lngRowCount
    Next i
    End If
    End With
    End If
    End Sub

    Is there a way to only populate comments on HCS Totals as it is typed and make the above macro automatic?! Help me pleeeease

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Concatenate Text Strings Across Worksheets HELP

    Hi bbruner and welcome to the forum,

    First your Char(10),Char(10) in the Concatinate function can be replaced with Rept(Char(10),2).
    That might make your long formula a little simpler.

    BUT - we really need to see a sample of your workbook to do a better job with this answer.
    You can attach a sample workbook by clicking on "Go Advanced" and then on the Paper Clip Icon above the advanced message area.

    ALSO - the forum moderator will give you a demerit if you don't edit your above post and put the code in code brackets. To do this, edit your post, select the VBA code and then click on the # icon above the message area. This will put "Code" tags around your code and you'll be safe.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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. How to concatenate two strings from two different .dat based text files using VBA
    By mahendra.asapu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-04-2015, 06:25 PM
  2. [SOLVED] Concatenate & format standard text in cell A1, Sheet1 with strings from two input boxes
    By mandora in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-27-2012, 04:22 AM
  3. Replies: 1
    Last Post: 12-20-2012, 04:18 PM
  4. [SOLVED] Macro to concatenate text strings
    By zcheema in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-23-2012, 03:12 PM
  5. Replies: 1
    Last Post: 02-10-2010, 02:00 PM
  6. Concatenate function to join some text strings
    By FRJ1949(Frank) in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-11-2010, 03:30 PM
  7. space between text strings with concatenate
    By Jeff in forum Excel General
    Replies: 2
    Last Post: 03-03-2005, 03:06 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