SlideShare a Scribd company logo
1 of 2
SubLastRowSearch()
DimLastRow AsLong
DimQuery2 AsListObject
If WorksheetFunction.CountA(Cells) >0 Then
'Search function'
lastrow1= Cells.Find(What:="*",After:=[A1],_
SearchOrder:=xlByRows,_
SearchDirection:=xlPrevious).Row
Worksheets("Sheet3").Activate
'.Find(What,After,LookIn,LookAt,SearchOrder,SearchDirection,MatchCase,MatchByte,
SearchFormat)'
LastRow2 = Cells.Find(What:="*",After:=[A1],_
SearchOrder:=xlByRows,_
SearchDirection:=xlPrevious).Row
'Copythe data fromsecondsheet'
Worksheets("Sheet3").Activate
ActiveSheet.Unprotect
Range("Query2").ListObject.QueryTable.RefreshBackgroundQuery:=False
Worksheets("Sheet3").Range("A2:F"&LastRow2).Copy
Worksheets("Sheet2").Activate
Worksheets("Sheet2").Range("a1").Select
'Create a name for the target destination
SetDest = Worksheets("Sheet2").Range("A"&lastrow1+ 1)
'paste the data into the newlyselectedfield
Dest.Select
Dest.PasteSpecialxlPasteValues
'CheckSheet2for duplicate values
ActiveSheet.Range("A:F").RemoveDuplicatesColumns:=Array(1,2,3, 4, 5, 6), _
Header:=xlYes
Range("A"&lastrow1+ 1).Select
End If
End Sub

More Related Content

What's hot

Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherence
aragozin
 

What's hot (20)

Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
 
14. containers, vector, list
14. containers, vector, list14. containers, vector, list
14. containers, vector, list
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email log
 
16 containers
16   containers16   containers
16 containers
 
Real World Generics In Swift
Real World Generics In SwiftReal World Generics In Swift
Real World Generics In Swift
 
Java ArrayList Tutorial | Edureka
Java ArrayList Tutorial | EdurekaJava ArrayList Tutorial | Edureka
Java ArrayList Tutorial | Edureka
 
Array vs array list
Array vs array listArray vs array list
Array vs array list
 
Js objects
Js objectsJs objects
Js objects
 
Api presentation
Api presentationApi presentation
Api presentation
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
 
strings and objects in JavaScript
strings and  objects in JavaScriptstrings and  objects in JavaScript
strings and objects in JavaScript
 
L11 array list
L11 array listL11 array list
L11 array list
 
An Exploration of the Formal Properties of PromQL
An Exploration of the Formal Properties of PromQLAn Exploration of the Formal Properties of PromQL
An Exploration of the Formal Properties of PromQL
 
Array list
Array listArray list
Array list
 
ArrayList in JAVA
ArrayList in JAVAArrayList in JAVA
ArrayList in JAVA
 
Python openpyxl
Python openpyxlPython openpyxl
Python openpyxl
 
Some Examples in R- [Data Visualization--R graphics]
 Some Examples in R- [Data Visualization--R graphics] Some Examples in R- [Data Visualization--R graphics]
Some Examples in R- [Data Visualization--R graphics]
 
Chapter 7: Queue data structure
Chapter 7:  Queue data structureChapter 7:  Queue data structure
Chapter 7: Queue data structure
 
قائمة القارات
قائمة القاراتقائمة القارات
قائمة القارات
 
Coherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherenceCoherence SIG: Advanced usage of indexes in coherence
Coherence SIG: Advanced usage of indexes in coherence
 

Similar to Blank Row Find and Select

Data structures in scala
Data structures in scalaData structures in scala
Data structures in scala
Meetu Maltiar
 

Similar to Blank Row Find and Select (20)

introduction_dst.pptx
introduction_dst.pptxintroduction_dst.pptx
introduction_dst.pptx
 
The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202
 
The Ring programming language version 1.5.1 book - Part 34 of 180
The Ring programming language version 1.5.1 book - Part 34 of 180The Ring programming language version 1.5.1 book - Part 34 of 180
The Ring programming language version 1.5.1 book - Part 34 of 180
 
The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210
 
Address calculation-sort
Address calculation-sortAddress calculation-sort
Address calculation-sort
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196
 
DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
 
The Ring programming language version 1.7 book - Part 39 of 196
The Ring programming language version 1.7 book - Part 39 of 196The Ring programming language version 1.7 book - Part 39 of 196
The Ring programming language version 1.7 book - Part 39 of 196
 
cluod.pdf
cluod.pdfcluod.pdf
cluod.pdf
 
The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.2 book - Part 23 of 84The Ring programming language version 1.2 book - Part 23 of 84
The Ring programming language version 1.2 book - Part 23 of 84
 
Jquery 1.3 cheatsheet_v1
Jquery 1.3 cheatsheet_v1Jquery 1.3 cheatsheet_v1
Jquery 1.3 cheatsheet_v1
 
Jquery 13 cheatsheet_v1
Jquery 13 cheatsheet_v1Jquery 13 cheatsheet_v1
Jquery 13 cheatsheet_v1
 
Stack & Queue
Stack & QueueStack & Queue
Stack & Queue
 
Data structures in scala
Data structures in scalaData structures in scala
Data structures in scala
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212
 
Queues & ITS TYPES
Queues & ITS TYPESQueues & ITS TYPES
Queues & ITS TYPES
 
III_Data Structure_Module_1.pptx
III_Data Structure_Module_1.pptxIII_Data Structure_Module_1.pptx
III_Data Structure_Module_1.pptx
 
purrr.pdf
purrr.pdfpurrr.pdf
purrr.pdf
 

Blank Row Find and Select

  • 1. SubLastRowSearch() DimLastRow AsLong DimQuery2 AsListObject If WorksheetFunction.CountA(Cells) >0 Then 'Search function' lastrow1= Cells.Find(What:="*",After:=[A1],_ SearchOrder:=xlByRows,_ SearchDirection:=xlPrevious).Row Worksheets("Sheet3").Activate '.Find(What,After,LookIn,LookAt,SearchOrder,SearchDirection,MatchCase,MatchByte, SearchFormat)' LastRow2 = Cells.Find(What:="*",After:=[A1],_ SearchOrder:=xlByRows,_ SearchDirection:=xlPrevious).Row 'Copythe data fromsecondsheet' Worksheets("Sheet3").Activate ActiveSheet.Unprotect Range("Query2").ListObject.QueryTable.RefreshBackgroundQuery:=False Worksheets("Sheet3").Range("A2:F"&LastRow2).Copy
  • 2. Worksheets("Sheet2").Activate Worksheets("Sheet2").Range("a1").Select 'Create a name for the target destination SetDest = Worksheets("Sheet2").Range("A"&lastrow1+ 1) 'paste the data into the newlyselectedfield Dest.Select Dest.PasteSpecialxlPasteValues 'CheckSheet2for duplicate values ActiveSheet.Range("A:F").RemoveDuplicatesColumns:=Array(1,2,3, 4, 5, 6), _ Header:=xlYes Range("A"&lastrow1+ 1).Select End If End Sub