Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies. Only from Platform Scholar.
Become a Premium Member and unlock a new, free course in leading technologies each month.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Sub x()
Dim v, i As Long
With Range("A1").CurrentRegion
v = .Value
.ClearContents
End With
For i = LBound(v, 1) To UBound(v, 1)
If v(i, 4) = "" Then
v(i, 4) = v(i, 2)
Else
v(i, 4) = v(i, 2) & " Sub " & v(i, 4)
End If
Next i
Range("A1").Resize(UBound(v, 1), 4) = v
End Sub
This did not work. I take it because the field is technically not blank
Dim iFirstColumn As Integer
Dim iSecondColumn As Integer
Dim iDestinationColumn As Integer
iDestinationColumn = 5
iFirstColumn = Val(InputBox("First column to pick?", "Pick", 2))
If iFirstColumn = 0 Then
Exit Sub
End If
iSecondColumn = Val(InputBox("Second column to pick?", "Pick", 4))
If iSecondColumn = 0 Then
Exit Sub
End If
Sub x()
Dim v, i As Long
Dim iFirstColumn As Integer
Dim iSecondColumn As Integer
Dim iDestinationColumn As Integer
iDestinationColumn = 5
iFirstColumn = Val(InputBox("First column to pick?", "Pick", 2))
If iFirstColumn = 0 Then
Exit Sub
End If
iSecondColumn = Val(InputBox("Second column to pick?", "Pick", 4))
If iSecondColumn = 0 Then
Exit Sub
End If
With Range("A1").CurrentRegion
v = .Value
.ClearContents
End With
For i = LBound(v, 1) To UBound(v, 1)
If v(i, iSecondColumn) = "" Then
v(i, iSecondColumn) = v(i, iFirstColumn)
Else
v(i, iSecondColumn) = v(i, iFirstColumn) & " Sub " & v(i, iSecondColumn)
End If
Next i
Range("A1").Resize(UBound(v, 1), 4)= v
End Sub
Sub x()
Dim v, i As Long
Dim iFirstColumn As Integer
Dim iSecondColumn As Integer
Dim iDestinationColumn As Integer
iDestinationColumn = 5
iFirstColumn = Val(InputBox("First column to pick?", "Pick", 2))
If iFirstColumn = 0 Then
Exit Sub
End If
iSecondColumn = Val(InputBox("Second column to pick?", "Pick", 4))
If iSecondColumn = 0 Then
Exit Sub
End If
With Range("A1").CurrentRegion
v = .Resize(, .Columns.Count + 1).Value
.ClearContents
End With
For i = LBound(v, 1) + 1 To UBound(v, 1)
If v(i, iSecondColumn) = "" Then
v(i, iDestinationColumn) = v(i, iFirstColumn)
Else
v(i, iDestinationColumn) = v(i, iFirstColumn) & " Sub " & v(i, iSecondColumn)
End If
Next i
Range("A1").Resize(UBound(v, 1), UBound(v, 2)) = v
End Sub
You can put it in your personal workbook and it will then be accessible all the time.
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.