do while loop problem

amitkumarsharma

New Member
Joined
Aug 31, 2016
Messages
10
i want to concatenate two columns
which are in between two yellow filled rows
but its concatenating for whole column till the end of column


Sub ConcatColumns()


Do While ActiveCellColor = NoFill 'Loops until the active cell is not coloured cell.



ActiveCell.Offset(0, 1).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & " " & ActiveCell.Offset(0, 0)


ActiveCell.Offset(1, 0).Select
Loop


End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
one more failed try using

Sub ConcatColumns()


Do While ActiveCellColor <> RGB(255, 255, 0) 'Loops until the active cell is blank.


'The "&" must have a space on both sides or it will be
'treated as a variable type of long integer.


ActiveCell.Offset(0, 1).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & " " & ActiveCell.Offset(0, 0)


ActiveCell.Offset(1, 0).Select
Loop


End Sub
 
Upvote 0
again one more fail , this time i tried with colour index
and concatenate between red rows

Sub ConcatColumns()


Do While ActiveCellColorIndex = 3 'Loops until the active cell is red.


'The "&" must have a space on both sides or it will be
'treated as a variable type of long integer.


ActiveCell.Offset(0, 1).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & " " & ActiveCell.Offset(0, 0)


ActiveCell.Offset(1, 0).Select
Loop


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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