Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a statement about if then
I am very new to this. I have a sheet - sheet 1 which has names in column b, c, d and if the number one is in column A on sheet one, I want it to pull the names in column b, c, d on sheet 1 to sheet 2 column b, c, d. If sheet 1 column a has z zero I want it to skip it and go to the next row with a number 1 in column A. You see, I only want the data on sheet 2 if I have a one in column 1. I want it to skip all records until it sees a One again in column a sheet one. Please help |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a statement about if then
run this macro:
Private Sub CommandButton1_Click() Set rngSource = Sheet1.Range("A1:C5") Set rngDest = Sheet2.Range("A1") j = 1 For i = 1 To rngSource.Rows.Count If rngSource(i, 1) = 1 Then rngDest(j, 2) = rngSource(i, 2) rngDest(j, 3) = rngSource(i, 3) rngDest(j, 4) = rngSource(i, 4) j = j + 1 End If Next i End Sub Mangesh "Baffle, Atlanta, Ga" wrote in message ... I am very new to this. I have a sheet - sheet 1 which has names in column b, c, d and if the number one is in column A on sheet one, I want it to pull the names in column b, c, d on sheet 1 to sheet 2 column b, c, d. If sheet 1 column a has z zero I want it to skip it and go to the next row with a number 1 in column A. You see, I only want the data on sheet 2 if I have a one in column 1. I want it to skip all records until it sees a One again in column a sheet one. Please help |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a statement about if then
Hi,
This will copy columns B,C and D. Place this code in a general module in your workbook. Sub CopySelectedRows() Dim iLastRow As Long Dim i As Long Dim rng As Range, outrng As Range Dim ws1 As Worksheet, ws2 As Worksheet Set ws1 = ActiveWorkbook.Worksheets("sheet1") Set ws2 = ActiveWorkbook.Worksheets("sheet2") Set outrng = ws2.Range("B2") ' Set outrng to 2nd row in sheet2 ws1.Activate With Activesheet iLastRow = Cells(Rows.Count, "A").End(xlUp).Row ' Find last row in column A For i = 2 To iLastRow ' Assumes header row If Cells(i, "A").Value = 1 Then Set rng = Cells(i, "B").Resize(1, 3) ' set range to columns B to D rng.Copy outrng ' Copy to sheet2 Set outrng = outrng.Offset(1, 0) ' set outrng to next row End If Next i End With End Sub "Baffle, Atlanta, Ga" wrote: I am very new to this. I have a sheet - sheet 1 which has names in column b, c, d and if the number one is in column A on sheet one, I want it to pull the names in column b, c, d on sheet 1 to sheet 2 column b, c, d. If sheet 1 column a has z zero I want it to skip it and go to the next row with a number 1 in column A. You see, I only want the data on sheet 2 if I have a one in column 1. I want it to skip all records until it sees a One again in column a sheet one. Please help |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
better way to write a count if statement? | Excel Worksheet Functions | |||
How do I write a basic VLOOKUP statement? | New Users to Excel | |||
How do I write a compound if statement? | Excel Worksheet Functions | |||
How do you write an if statement that replaces #DIV/0! with 0 | Excel Discussion (Misc queries) | |||
how do I write the date in an if statement | Excel Worksheet Functions |