Concatenate cells in VBA (Variables)

Andresuru

New Member
Joined
Sep 6, 2021
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hello Everyone

First time posting here so I appreciate a little bit patience jaja.
I would like to someone if someone can help me with the next code:

Expectation: (Concatenate values from the activecell to last cell <> Empty) for each cell in range("B1:B350000")

'The values are string or text

Sub EasyWay()

Application.ScreenUpdating = False

Dim cell As Range, celda As Range
Dim First As Long, Lastone As Long
Dim Concatenate As String, str1 As String, str2 As String


Sheets("Data Dictionary").Select
Range("B:B").Select

First = ActiveCell + 1
Lastone = IsNumeric(cell) - 1

str1 = ActiveCell
str2 = ActiveCell(1, 0)


'On Error Resume Next


For Each cell In Range("B1:B350000")

If IsNumeric(cell) = False Or cell = Empty Then


Else

If IsNumeric(cell) = True Then

cell.Select
Selection.Cut
ActiveCell.Offset(0, -1).Select
ActiveSheet.Paste

ActiveCell.Offset(1, 1).Select



'HELPING TO CREATE CODE
'______________________________________________________________________________________________

I try many different ways but I need to find the solution

For i = First To Lastone

If Cells(1, 2) <> Empty Then

ActiveCell.Value = Cells(i, 2) & Cells(1 + 1, 2)

End If
Next i

'____________________________________________________________________________________________________

End If




End If
Next cell



'Call DeleteEmptyCells

End Sub


Sub DeleteEmptyCells2()

'Eliminas las filas en blanco en la columna D

Application.ScreenUpdating = False
Sheets("Data Dictionary").Select
Range("B:B").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete

End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Basically the reference about which cells I need to concatenate is variable because I have a big report under 35k rows and the code needs to know that every time a number is founded in column B, select the cell cut and paste to left and then (HELP CODE) I need to concatenate the red square in the blue square for each numeric founded (This part already resolved)
 

Attachments

  • Capture.JPG
    Capture.JPG
    69.4 KB · Views: 7
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Concatenate Cells According a condition
and here Concatenate Cells According a condition - OzGrid Free Excel/VBA Help Forum
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,706
Members
449,118
Latest member
MichealRed

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