List text in column without spaces from a spreadsheet if numerical values greater than 0

Dan1000

Board Regular
Joined
Nov 4, 2006
Messages
210
I have a spreadsheet with text strings in some of one column with numerical values against the text in a neighbouring column, and with '0' values or blank cells against the empty text cells. I would like to extract the text data to another spreadsheet based on the numerical values being above 0 using VBA code so that the text values read from top to bottom without any empty cells and leaving them in alphabetical order.

Any help would be gratefully appreciated.


Dan
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
In which column are the text strings and are they already in alphabetical order? Are the "0" values and blanks in the neighbouring column entered manually or the result of a formula?
 
Upvote 0
Hi Mumps

Specifically...

The text is in alternate cells in column L and are not necessarily already in alphabetical order,
The numerical values are in column M,
The numerical values sum up the random numerical values in each respective row some of which add up to 0 but its the ones that have 1 or more I need to extract


Regards

Dan
 
Upvote 0
Try:
Code:
Sub Dan1000()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Range("L1:M" & LastRow).AutoFilter Field:=1, Criteria1:="<>"
    Range("L1:M" & LastRow).AutoFilter Field:=2, Criteria1:=">0"
    Range("L2:L" & LastRow).SpecialCells(xlCellTypeVisible).Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Range("L1").AutoFilter
    Application.ScreenUpdating = True
End Sub
Data will be copied to Sheet2.
 
Upvote 0
Brings up runtime error 1004 and inserts the header and the first item several times into sheet2?


Dan
 
Upvote 0
Example: sheet1

Item1Quantity
Text110
Text2
Text4
Text3
Text5
Text65
Text75
Text9
Text105

<colgroup><col width="87" span="2" style="width: 65pt;"></colgroup><tbody>
</tbody>

Outcome: sheet2

Text110
Text65
Text75
Text105

<colgroup><col width="87" span="2" style="width: 65pt;"></colgroup><tbody>
</tbody>

Note, first column is in alphabetical order and does not have a header. I need to locate the list a few rows down and a few columns across -first text item in H13 - and so some advice on how to adjust / make this happen would also be helpful


Dan
 
Upvote 0
This information
few rows down and a few columns across
doesn't really help. The macro needs precise information. I think that it would be easier to help and test possible solutions if I could work with your actual file which includes any macros you are currently using. Perhaps you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do using a few examples from your data and referring to specific cells, rows, columns and worksheets. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,016
Members
448,936
Latest member
almerpogi

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