How to concatenate single cell from variable number of sheets?

valeriewong1

New Member
Joined
Jul 24, 2012
Messages
4
Hi guys,

I'm trying to concatenate data from cell A65 across a variable number of identical sheets to cell G7 on a separate worksheet. Does anyone know how to do this using a UDF, preferably with spaces between the data from each cell? Thanks in advance!

Valerie
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Welcome to Board!
Try this:

Code:
Function ConCatSht(cel As String) As String
ConCatSht = ""
For Each ws In Worksheets 'exclude the Master sheet
    If ws.Name <> "Master" Then ConCatSht = ConCatSht & " " & ws.Range(cel).Value
Next ws
End Function
Put this in a code module.

Usage:
=ConCatSht("A65")

Change the name "Master" above to sheet name where G7 data goes.
 
Upvote 0
Thanks for the quick reply! Just to clarify, though, I am working with a few other sheets besides the master sheet and the identical sheets where I want to copy the information from cell A65. Is there any way to exclude those sheets from the formula? Thanks again!

Welcome to Board!
Try this:

Code:
Function ConCatSht(cel As String) As String
ConCatSht = ""
For Each ws In Worksheets 'exclude the Master sheet
    If ws.Name <> "Master" Then ConCatSht = ConCatSht & " " & ws.Range(cel).Value
Next ws
End Function
Put this in a code module.

Usage:
=ConCatSht("A65")

Change the name "Master" above to sheet name where G7 data goes.
 
Upvote 0
This should work:
Code:
Function ConCatSht(cel As String) As String
ConCatSht = ""
For Each ws In Worksheets 'exclude the Master and other sheets
    If Not IsError(Application.Match(ws.Name, Array("Sheet1", "Sheet2", "Master"), 0)) Then
        ConCatSht = ConCatSht & " " & ws.Range(cel).Value
    End If
Next ws
End Function

Write all the sheet names to EXCLUDE within Array(...) above.
 
Upvote 0
I've tried inserting the following code into a code module and inserting the formula =ConCatSht("A65") into the destination cell G7, but nothing seems to be appearing in the cell. Any idea what I'm doing wrong? I've tried inserting the name of the Master sheet into the "Master" bit of the code, but no luck.

Function ConCatSht(cel As String) As String
ConCatSht = ""
For Each ws In Worksheets 'exclude the Master and other sheets
If Not IsError(Application.Match(ws.Name, Array("Pre-Meeting BG Info", "Handover Email", "Master"), 0)) Then
ConCatSht = ConCatSht & " " & ws.Range(cel).Value
End If
Next ws
End Function
 
Upvote 0
I think that drsarao meant

If IsError(Application.Match(ws.Name, Array("Pre-Meeting BG Info", "Handover Email", "Master"), 0)) Then
ConCatSht = ConCatSht & " " & ws.Range(cel).Value
End If

instead of

If Not IsError(....

to exclude sheets within the array.

M.
 
Upvote 0
Marcelo,
Thanks for the correction. Not is a bugbear for me!
It is indeed:
Code:
Function ConCatSht(cel As String) As String
ConCatSht = ""
For Each ws In Worksheets 'exclude the Master and other sheets
    If IsError(Application.Match(ws.Name, Array("Sheet1", "Sheet2", "Master"), 0)) Then
        ConCatSht = ConCatSht & " " & ws.Range(cel).Value
    End If
Next ws
End Function
 
Upvote 0
You are welcome and thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top