how to repeat column B names. Is there any another way rather than dragging the cells?

srija

New Member
Joined
Jan 29, 2020
Messages
22
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
Please help me that how can we repeat column B names (vamsi and suresh) until cell value = EOH12 (column A).

A column I B column
E0H11 vamsi
E0H24 suresh
E0H01 (Repeat here)
E0H54 (Repeat here)
EOH12 (Repeat here)

Output should be like:
A column I B column

E0H11 vamsi
E0H24 suresh
E0H01 vamsi
E0H54 suresh
EOH12 vamsi

Please help me out:)
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome
If one time task select both name and simple drag-down-copy them.
 
Upvote 0
put this in B1 then copy down

=IF(MOD(ROWS($A$1:A1),2)>0,A1&" vamsi",A1&" suresh")
 
Upvote 0
If the cell below EOH12 is blank, select the two cells in column B and double click the lower right corner of the selection.
 
Upvote 0
Hey, Thank you for your response but I have to repeat this process for many names like this. Is there any way to do automatically by click one #button(VBA or any) without dragging option.

Ex: if we enter names in any data form or in certain cells then it should get repeat itself(automatically) based on already filled A column values.

A column B column

E0H11 vamsi

E0H24 suresh

E0H01 mahesh

E0H54 (Repeat here)

EOH12 (Repeat here)


Output should be like:

A column B column

E0H11 vamsi

E0H24 suresh

E0H01 mahesh

E0H54 vamsi

EOH12 suresh
 
Upvote 0
Assuming a data set like this:
Book1
AB
1E0H11vamsi
2E0H24suresh
3E0H01mahesh
4E0H54
5E0H55
6E0H56
7E0H57
8E0H58
9E0H59
10E0H60
11E0H61
12E0H62
13E0H12
14E0H70
15E0H71
16E0H72
17E0H73
18E0H74
19E0H75
20E0H76
Sheet2

This macro:
VBA Code:
Sub RepeatNames()
'assumes no blank cells between the first entry in col A and the EOH12 entry in col A
Dim lRA As Long, lRB As Long, Nams As Variant, Ct As Long
lRA = Range("A:A").Find("E0H12", , xlValues, xlWhole, MatchCase:=False).Row: lRB = Cells(Rows.Count, "B").End(xlUp).Row
Nams = Application.Transpose(Range("B1:B" & lRB))
Ct = 1
Application.ScreenUpdating = False
For i = lRB + 1 To lRA
    Cells(i, "B").Value = Nams(Ct)
    If Ct = UBound(Nams) Then
        Ct = 1
    Else
        Ct = Ct + 1
    End If
Next i
Application.ScreenUpdating = True
End Sub
Will produce this result:
Book1
AB
1E0H11vamsi
2E0H24suresh
3E0H01mahesh
4E0H54vamsi
5E0H55suresh
6E0H56mahesh
7E0H57vamsi
8E0H58suresh
9E0H59mahesh
10E0H60vamsi
11E0H61suresh
12E0H62mahesh
13E0H12vamsi
14E0H70
15E0H71
16E0H72
17E0H73
18E0H74
19E0H75
20E0H76
Sheet2
 
Upvote 0
"I have to repeat this process for many names like this"
You need to provide details/examples of what this involves.

If you just want to do it for the example data provided (and assuming the data starts in row 2) :
VBA Code:
Range("B2:B" & Cells(Rows.Count, "B").End(3).Row).AutoFill Destination:=Range("B2:B" & Cells(Rows.Count, "A").End(3).Row)
 
Upvote 0
Thanks for your response, below one is working fine for me.
I need one more help. Please let me know on the below two

1. How to skip hidden cells while repeating names using below code.
2. If I don't want to paste names where ever the value "E0H24 " is in A. How to make it.

VBA Code:
Sub RepeatNames()
    Dim lrow As Integer
    lrow = Range("A2").End(xlDown).Row
Range("B2:B" & Cells(Rows.Count, "B").End(3).Row).AutoFill Destination:=Range("B2:B" & Cells(Rows.Count, "A").End(3).Row)
End Sub
 
Upvote 0
1. How to skip hidden cells while repeating names using below code.
2. If I don't want to paste names where ever the value "E0H24 " is in A. How to make it.
Provide sample data before and after the names are filled down.
 
Upvote 0
Here is the data
main1.PNG


Im getting output like this, names are not in order

res.PNG


result should be like below even after hiding cells( i don't want to add names for "E0H1"[hidden cell]). I wanna add names to visible cells only. Do I need to use special paste, How? But I cannot remove any data form these cells.

resn.PNG


Thank you
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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