ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   fill in data that is not empty (https://www.excelbanter.com/excel-programming/447394-fill-data-not-empty.html)

Tariq Khalaf

fill in data that is not empty
 
I have a list of products listed on one worksheet, but not every product will have a value. In a separate worksheet I want it to only pull over the products that have values. I have been able to output the fist column of pizza but pizza-crust will not continue

Sheet 1 called prices

list pizza pizza-crust pizza-thin
pepper 1 5 8
beef 2
bacon 3 6
pineapple 4 9
mushroom 7 10
The macro that I have does the following

list pizza
pepper 1
beef 2
bacon 3
pineapple 4
how can i get it to fill in the data for the rest of the columns so that it would put pizza crust and then the data for each and then put pizza-thin and the data for that

below is the macro

Sub Button2_Click()
Dim column As Integer
column = 1
newrow = 1
Do Until Worksheets("sheet1").Cells(column, 1).Value = ""

If Worksheets("sheet1").Cells(column, 2).Value < "" Then

Worksheets("sheet2").Cells(newrow, 1).Value = Worksheets("sheet1").Cells(column, 1).Value
Worksheets("sheet2").Cells(newrow, 2).Value = Worksheets("sheet1").Cells(column, 2).Value

newrow = newrow + 1
End If
column = column + 1
Loop
End Sub
thanks

Don Guillett[_2_]

fill in data that is not empty
 
On Tuesday, October 16, 2012 8:29:59 AM UTC-5, Tariq Khalaf wrote:
I have a list of products listed on one worksheet, but not every product will have a value. In a separate worksheet I want it to only pull over the products that have values. I have been able to output the fist column of pizza but pizza-crust will not continue



Sheet 1 called prices



list pizza pizza-crust pizza-thin

pepper 1 5 8

beef 2

bacon 3 6

pineapple 4 9

mushroom 7 10

The macro that I have does the following



list pizza

pepper 1

beef 2

bacon 3

pineapple 4

how can i get it to fill in the data for the rest of the columns so that it would put pizza crust and then the data for each and then put pizza-thin and the data for that



below is the macro



Sub Button2_Click()

Dim column As Integer

column = 1

newrow = 1

Do Until Worksheets("sheet1").Cells(column, 1).Value = ""



If Worksheets("sheet1").Cells(column, 2).Value < "" Then



Worksheets("sheet2").Cells(newrow, 1).Value = Worksheets("sheet1").Cells(column, 1).Value

Worksheets("sheet2").Cells(newrow, 2).Value = Worksheets("sheet1").Cells(column, 2).Value



newrow = newrow + 1

End If

column = column + 1

Loop

End Sub

thanks


Different ways. Reply to dguillett1 @gmail.com with your file.


All times are GMT +1. The time now is 02:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com