I have a table of data which has been imported to a sheet and need to delete some random contents, then copy a title down until the next title. For example, as attached. Column A will have a formula of B&" "&C and has to be this way due to vlookups in another table. The headers (bold e.g. 'London', 'Leeds', 'Manchester') have random sub contents (not in bold) that needs to be deleted, and then the header needs to be copied down underneath until the next header. Problem is that these headers are not fixed in a row and can move up and down dependant on the data in the download. They will always be in column B, and the 'field' will always be in column C. Thanks
delete, copy, paste within limits
-
-
Re: delete, copy, paste within limits
OK, found one suitable
Code
Display MoreSub FillColBlanks() 'http://www.contextures.com/xlDataEntry02.html 'by Dave Peterson 2004-01-06 'fill blank cells in column with value above '2010-10-12 incorporated Ron de Bruin's test for special cells limit 'http://www.rondebruin.nl/specialcells.htm Dim wks As Worksheet Dim rng As Range Dim rng2 As Range Dim LastRow As Long Dim col As Long Dim lRows As Long Dim lLimit As Long Dim lCount As Long On Error Resume Next lRows = 2 'starting row lLimit = 8000 Set wks = ActiveSheet With wks col = ActiveCell.Column Set rng = .UsedRange 'try to reset the lastcell LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row Set rng = Nothing lCount = .Columns(col).SpecialCells(xlCellTypeBlanks).Areas(1).Cells.Count If lCount = 0 Then MsgBox "No blanks found in selected column" Exit Sub ElseIf lCount = .Columns(col).Cells.Count Then MsgBox "Over the Special Cells Limit" 'this line can be deleted Do While lRows < LastRow Set rng = .Range(.Cells(lRows, col), .Cells(lRows + lLimit, col)) _ .Cells.SpecialCells(xlCellTypeBlanks) rng.FormulaR1C1 = "=R[-1]C" lRows = lRows + lLimit Loop Else Set rng = .Range(.Cells(2, col), .Cells(LastRow, col)) _ .Cells.SpecialCells(xlCellTypeBlanks) rng.FormulaR1C1 = "=R[-1]C" End If 'replace formulas with values With .Cells(1, col).EntireColumn .Value = .Value End With End With End Sub
-
Re: delete, copy, paste within limits
freddie0,
Does the macro you posted fill your needs?
If not:
QuoteThe headers (bold e.g. 'London', 'Leeds',
'Manchester')
Is there always one blank row between the last field in group 'London" to the title 'Leeds'?
Is there always one blank row between the last field in group 'Leeds" to the title 'Manchester'?
Have a great day,
Stan -
Re: delete, copy, paste within limits
All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.
I've added the tags for you this time only. Be sure to use them in future posts.[COLOR="navy"]How to use code tags[/COLOR]
[noparse]
[/noparse]
-
Re: delete, copy, paste within limits
Quote from Stanley D. Grom;558427freddie0, Does the macro you posted fill your needs? If not: Is there always one blank row between the last field in group 'London" to the title 'Leeds'? Is there always one blank row between the last field in group 'Leeds" to the title 'Manchester'? Have a great day,Stan
Hi StanThe method posted suits fine thanks. It is a set of numbers (results) from a csv paste horizontally with no gaps, just consecutive numbers.The code I used allows the transpose to vertical and gives the option of how many rows to insertThanks
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!