Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other C# .NET Posts   Ask New Question  Ask New Question With Power Editor

how to find last row after some rows have been deleted
Ileana Gonzalez posted at Thursday, November 05, 2009 12:20 PM

Hello, i have 2 problems,
#1. at the beginning of my code, I dimmed a lastrow variable to find the last row of the file and then delete the duplicates in the ID filed until the last row (the file may not always have same amount of rows). That works fine. Later I dimmed another lastrow2 variable that I want it to find the last row after the duplicates have been removed. the problem is the lastrow2 variable gives me the same count of rows as the lastrow variable even after some rows have been deleted.

what can i do?

#2. after lastrow2 finds the last row I'm going to have a formula on the first row that i want to copy all the way down until the last row, code seems not to be working

i have posted that part of my code below

any ideas?

 

'find last row after the dupliactes have been removed
    Dim lastRowAfterDuplicatesRemoved As Long
    lastRowAfterDuplicatesRemoved = ActiveSheet.UsedRange.Rows.Count
    MsgBox (lastRowAfterDuplicatesRemoved)

'index the counties by matching zip codes
    Range("N2").Select
    ActiveCell.FormulaR1C1 = _
        "=INDEX('[All zip codes in FL.xlsx]Sheet1'!R2C1:R1450C4,MATCH(RC[-4],'[All zip codes in FL.xlsx]Sheet1'!R2C1:R1450C1,0),4)"
    Selection.Copy
    Range("N3:N" & lastRowAfterDuplicatesRemoved).Select
    ActiveSheet.Paste
    Range("N2:N" & lastRowAfterDuplicatesRemoved).Select
   Application.CutCopyMode = False

'paste special values
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
   

 

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0