![]() |
Which commands to use in a macro
Hi,
I want to use a macro in a worksheet. In the worksheet, I have to select only some columns, not all. Now, the number of rows are also refreshed daily in that sheet. I have to apply conditions also in that macro for selecting the particular rows. Can I use if statement in the VB editor, and what command should i use with if to select a particular cell? Activecell? For example, I have to select column 3, 8 and 10 and check for all rows which have a value in column 5 equal to 0. Then I have to copy these rows in another sheet. Please help me out. Thanks in advance. |
Which commands to use in a macro
Hello Alok, Do you mean that if any row in column 5 ("E") is equal to zero tha columns 3, 8, and 10 ("C", "H", "J") in that same row will be copied t a another sheet? Sincerely, Leith Ros -- Leith Ros ----------------------------------------------------------------------- Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846 View this thread: http://www.excelforum.com/showthread.php?threadid=50624 |
Which commands to use in a macro
Guessing a bit
Sub CopyData() Dim oRow As Range Dim rng As Range Dim i As Long For Each oRow In ActiveSheet.UsedRange.Rows If Cells(oRow.Row, "E").Value = 0 Then i = i + 1 Cells(oRow.Row, "C").Copy Worksheets("Sheet2").Range("A" & i) Cells(oRow.Row, "H").Copy Worksheets("Sheet2").Range("B" & i) Cells(oRow.Row, "J").Copy Worksheets("Sheet2").Range("C" & i) End If Next oRow End Sub -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Alok" wrote in message ... Hi, I want to use a macro in a worksheet. In the worksheet, I have to select only some columns, not all. Now, the number of rows are also refreshed daily in that sheet. I have to apply conditions also in that macro for selecting the particular rows. Can I use if statement in the VB editor, and what command should i use with if to select a particular cell? Activecell? For example, I have to select column 3, 8 and 10 and check for all rows which have a value in column 5 equal to 0. Then I have to copy these rows in another sheet. Please help me out. Thanks in advance. |
All times are GMT +1. The time now is 05:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com