Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi jhahes,
You might want to try something like this ... Sub AddUniquesToSheet() Dim wsLook As Worksheet, wsFind As Worksheet Dim rngFind As Range Dim LastRow As Long, i As Long, SheetLastRow Set wsLook = Sheets("Sheet1") Set wsFind = Sheets("Sheet15") LastRow = wsLook.Cells(Rows.Count, "A").End(xlUp).Row For i = 2 To LastRow Set rngFind = wsFind.Range("A:A").Find(wsLook.Range("A" & i), lookat:=xlWhole, MatchCase:=True) If rngFind Is Nothing Then SheetLastRow = wsFind.Cells(Rows.Count, "A").End(xlUp).Row wsFind.Cells(SheetLastRow + 1, "A").Value = wsLook.Range("A" & i).Value End If Set rngFind = Nothing Next i End Sub HTH -- Regards, Zack Barresse, aka firefytr To email, remove NOSPAM "jhahes" wrote in message ... I am novice in vba so I will try to explain what I need and show you what I have. I have about 200 rows in Column A of Sheet 1 (all number format, all unique) I want to have the code select the first number in the column (A2) Then Go to sheet 15 Column A to see if the number is there. If it isn't there then put it in the next available row in Column A. I want this to loop through all the 200 rows in Column A of Sheet 1 and do the same thing. Here is what I have so far, I know it is probably very tedious. My problem is I don't know how to store the first activecell to reference to: If Sheet1.Visible = xlSheetHidden Then Sheet1.Visible = xlSheetVisible End If Sheet1.Activate Range("A2").Select If ActiveCell.Offset(0, 5).Value < "" Then If Sheet15.Visible = xlSheetHidden Then Sheet15.Visible = xlSheetVisible End If Sheet15.Activate Range("A2").Select Do If ActiveCell.Value < FirstActiveCell.Value Then ActiveCell.Offset(1, 0).Select End If Loop Until ActiveCell.Value = FirstActiveCell.Value Or ActiveCell.Row = 1000 If ActiveCell.Row = 1000 Then Range("A2").Select Do If IsEmpty(activcell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = FirstActiveCell.Value -- jhahes ------------------------------------------------------------------------ jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596 View this thread: http://www.excelforum.com/showthread...hreadid=530586 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
use time functions inside if loop | Excel Worksheet Functions | |||
Create an array inside a For...Next loop | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
declaring active cell inside a for loop and offsetting from it | Excel Programming |