ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find and print in new sheet (https://www.excelbanter.com/excel-programming/335421-find-print-new-sheet.html)

SajberSmurf

Find and print in new sheet
 
I want to make an function that looks for an number in one worksheet and copy
it in a new worksheet. like IF(A1=2;"testing";"0") but i dont want it to
write 0 or leave the line empty and jump down,
For exampel if a1= 1 then write b1 and d1
If a2=2 dont write anything but find next 1 and write that on next row in
new worksheet.


Tom Ogilvy

Find and print in new sheet
 
Sub ABCD()
Dim k as Long, cell as Range, rng as Range
k = 1
set rng = Worksheets("Sheet2").Range("A1")
with worksheets("sheet1")
for each cell in .Range("A1:A20")
if cell.Value = 1 then
rng(k,1) = cell.offset(0,1)
rng(k,2) = cell.offset(0,3)
k = k + 1
end if
Next
End with
End Sub


--
Regards,
Tom Ogilvy

"SajberSmurf" wrote in message
...
I want to make an function that looks for an number in one worksheet and

copy
it in a new worksheet. like IF(A1=2;"testing";"0") but i dont want it to
write 0 or leave the line empty and jump down,
For exampel if a1= 1 then write b1 and d1
If a2=2 dont write anything but find next 1 and write that on next row in
new worksheet.





All times are GMT +1. The time now is 11:06 PM.

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