please help - concatenate vba

mrfranke

New Member
Joined
Jul 21, 2010
Messages
6
hi all, i have a problem with concatemate function.. i found some but need help, argumets range in function concrange must be in [a1:c1] format .. but i need to run function in cycle fe. for range [a1:c1] offset (Row, 0) ... here´s code

Function ConcRange(Substrings As Range, Optional Delim As String = "", _
Optional AsDisplayed As Boolean = False, Optional SkipBlanks As Boolean = False)

Dim CLL As Range

For Each CLL In Substrings.Cells
If Not (SkipBlanks And Trim(CLL) = "") Then
ConcRange = ConcRange & Delim & IIf(AsDisplayed, Trim(CLL.Text), Trim(CLL.Value))
End If
Next CLL

ConcRange = Mid$(ConcRange, Len(Delim) + 1)

End Function


Sub OpenMultipleFiles()

Dim Filter As String, Title As String, fName As String
Dim FilterIndex As Integer
Dim Filename As Variant
Dim sFileName As String
Dim pocetsloupcu, jmeno, nejmeno, bunka, aktivni, RowBE, RowCH, s
Dim SomeVariable
Dim myrange



pocetsloupcu = 0
RowBE = 0
RowCH = 0

Set Inpt_DATA = Workbooks(ThisWorkbook.Name).Worksheets("Sheet1")

' File filters
Filter = "Excel Files (*.xls),*.xls," & _
"Text Files (*.txt),*.txt," & _
"All Files (*.*),*.*"
' Default Filter to *.*
FilterIndex = 3
' Set Dialog Caption
Title = "Select a File to Open"
' Select Start Drive & Path
ChDrive ("C")
ChDir ("C:\Documents and Settings\xxxxxx")
With Application
' Set File Name to selected File
Filename = .GetOpenFilename(Filter, FilterIndex, Title, True)
sFileName = Application.GetOpenFilename
' Reset Start Drive/Path
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
' Exit on Cancel
If Filename = False Then
MsgBox "No file was selected."
Exit Sub
End If
' Open File
Workbooks.Open Filename


Sheets("Data").Select
Range("B2").Select


Do While Not IsEmpty(ActiveCell) 'count number of the row, which will be use for copy
pocetsloupcu = pocetsloupcu + 1
ActiveCell.Offset(1, 0).Select
Loop

ActiveSheet.Unprotect
ActiveWorkbook.Unprotect
Application.DisplayAlerts = False


'For Row = 0 To pocetsloupcu
'Range("B2:AA2").Offset(Row, 0).Copy 'Workbooks("Book1.xls").Sheets("Sheet1").Range("A2").Offset(RowBE, 0)
'RowBE = RowBE + 1
' Range("AB2").Offset(Row, 0).Copy
' RowCH = RowCH + 1
'Next Row

For Row = 0 To pocetsloupcu
Range("AF1").Offset(Row, 0).Value = SomeVariable
SomeVariable = ConcRange(ActiveSheet.[AC2:AE2], ", ")
Next Row



Could some help me how to make it work in cycle for cells [AC2:AE2] . offset(Row, 0)??? Thanks a lot[/B

End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Maybe:
Code:
SomeVariable = ConcRange(Range("AC1").Offset(Row, 0).ReSize(1,3), ", ")
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,405
Members
452,911
Latest member
a_barila

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