need all in the same row if we have a letter

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
996
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team

I have data inwhich for few cell due to letter is it comming in 2 line but i need i same cell so that i can consider in same row....

Book1
ABCDEFGHIJKL
6Unaided Brand Awareness - First mention45513774233465142645-6
7CC
8Unaided Brand Awareness - Any mention456039781839751537644
9Aided Brand Awareness451005010004994-65798-2
10B
11Brand Favorability45874284-34281-650860
12Purchase Intent45873876-114077-1050860
13Brand Affinity45692550-193262-744767
14A
Sheet2
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Assuming your cells aren't merged then try the code below (although you haven't stated what you want the result to look like)

VBA Code:
Sub sksanjeev786()
   Dim lr As Long, i As Long
   Application.ScreenUpdating = False
   
    lr = Cells(Rows.Count, "A").End(xlUp).Row
  
   For i = lr To 6 Step -1
        If Left(Cells(i, "F"), 1) Like "[A-Za-z]" Then
            Cells(i, "F").Offset(-1).Value = Cells(i, "F").Offset(-1).Value & Cells(i, "F").Value
            Cells(i, "F").EntireRow.Delete
        End If
    Next

End Sub
 
Last edited:
Upvote 0
Assuming your cells aren't merged then try the code below (although you haven't stated what you want the result to look like)

VBA Code:
Sub sksanjeev786()
   Dim lr As Long, i As Long
   Application.ScreenUpdating = False
  
    lr = Cells(Rows.Count, "A").End(xlUp).Row
 
   For i = lr To 6 Step -1
        If Left(Cells(i, "F"), 1) Like "[A-Za-z]" Then
            Cells(i, "F").Offset(-1).Value = Cells(i, "F").Offset(-1).Value & Cells(i, "F").Value
            Cells(i, "F").EntireRow.Delete
        End If
    Next

End Sub
Hey Mark,

Thanks for your time on this.

I have tried with above Macro and not able to see any changes after appyig same on above data.

Regards
Sanjeev
 
Upvote 0
When I run the the code it changes from
Book1
ABCDEFGHIJKL
6Unaided Brand Awareness - First mention45513774233465142645-6
7CC
8Unaided Brand Awareness - Any mention456039781839751537644
9Aided Brand Awareness451005010004994-65798-2
10B
11Brand Favorability45874284-34281-650860
12Purchase Intent45873876-114077-1050860
13Brand Affinity45692550-193262-744767
14A
Sheet2

to
Book1
ABCDEFGHIJKL
6Unaided Brand Awareness - First mention4551377423C3465142645-6
7Unaided Brand Awareness - Any mention456039781839751537644
8Aided Brand Awareness45100501000B4994-65798-2
9Brand Favorability45874284-34281-650860
10Purchase Intent45873876-114077-1050860
11Brand Affinity45692550-193262-744767
12A
Sheet2

Note column F

Although I now see you have letters in other columns further along and so I will have to recode for this
 
Upvote 0
Code below adjusted for more columns and multiple entries in the columns
VBA Code:
Sub sksanjeev786B()
    Dim lr As Long, i As Long, j As Integer, k As Integer
    Application.ScreenUpdating = False
   
    lr = Cells(Rows.Count, "A").End(xlUp).Row
   
    For j = 2 To 12
       
        For i = lr To 6 Step -1
           
            If Left(Cells(i, j), 1) Like "[A-Za-z]" Then
                For k = 2 To 12
                    If Left(Cells(i, k), 1) Like "[A-Za-z]" Then
                        Cells(i, k).Offset(-1).Value = Cells(i, k).Offset(-1).Value & Cells(i, k).Value
                    End If
                Next
                Cells(i, j).EntireRow.Delete
            End If
       
        Next
   
    Next
End Sub
For me changes

Book1
ABCDEFGHIJKL
6Unaided Brand Awareness - First mention45513774233465142645-6
7CC
8Unaided Brand Awareness - Any mention456039781839751537644
9Aided Brand Awareness451005010004994-65798-2
10B
11Brand Favorability45874284-34281-650860
12Purchase Intent45873876-114077-1050860
13Brand Affinity45692550-193262-744767
14A
Sheet3


to

Book1
ABCDEFGHIJKL
6Unaided Brand Awareness - First mention4551377423C346514C2645-6
7Unaided Brand Awareness - Any mention456039781839751537644
8Aided Brand Awareness45100501000B4994-65798-2
9Brand Favorability45874284-34281-650860
10Purchase Intent45873876-114077-1050860
11Brand Affinity45692550-193262-744767A
12
13
14
Sheet3
 
Upvote 1
Solution
Code below adjusted for more columns and multiple entries in the columns
VBA Code:
Sub sksanjeev786B()
    Dim lr As Long, i As Long, j As Integer, k As Integer
    Application.ScreenUpdating = False
  
    lr = Cells(Rows.Count, "A").End(xlUp).Row
  
    For j = 2 To 12
      
        For i = lr To 6 Step -1
          
            If Left(Cells(i, j), 1) Like "[A-Za-z]" Then
                For k = 2 To 12
                    If Left(Cells(i, k), 1) Like "[A-Za-z]" Then
                        Cells(i, k).Offset(-1).Value = Cells(i, k).Offset(-1).Value & Cells(i, k).Value
                    End If
                Next
                Cells(i, j).EntireRow.Delete
            End If
      
        Next
  
    Next
End Sub
For me changes

Book1
ABCDEFGHIJKL
6Unaided Brand Awareness - First mention45513774233465142645-6
7CC
8Unaided Brand Awareness - Any mention456039781839751537644
9Aided Brand Awareness451005010004994-65798-2
10B
11Brand Favorability45874284-34281-650860
12Purchase Intent45873876-114077-1050860
13Brand Affinity45692550-193262-744767
14A
Sheet3


to

Book1
ABCDEFGHIJKL
6Unaided Brand Awareness - First mention4551377423C346514C2645-6
7Unaided Brand Awareness - Any mention456039781839751537644
8Aided Brand Awareness45100501000B4994-65798-2
9Brand Favorability45874284-34281-650860
10Purchase Intent45873876-114077-1050860
11Brand Affinity45692550-193262-744767A
12
13
14
Sheet3
Thank you so much!! for your help with this.


Regards
Sanjeev
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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