Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2009, 08:19 PM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find and Select but how?

I need some help.

I receive lots of files that contain rows of data. The last column for the data is always column y.

In some of my files I need to find the cell that is in column Y in the last row of data and if it is empty I need to add A1 into the cell. If it already contains data I do not need to add A1.

Although Column Y in the last row may not contain data, there will be data in a number of the other cells in the last row.

all help is appreciated.
 
Old August 21st, 2009, 12:22 AM
Authorized User
 
Join Date: Mar 2008
Location: , , Russia.
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via ICQ to sektor
Default

The problem is that first you gotta define REAL last row. For instance, you can define last row in column X:

Code:
Dim lastRow As Long
lastRow = Range("X1").End(xlDown).Row

After that you can check your last cell in column Y:
Code:
Dim lastCell As Range
Set lastCell = Cells(lastRow, "Y")

And then you can check, whether this cell is empty, and if it is, then copy your A1 cell into that last cell in Y column:
Code:
If IsEmpty(lastCell) Then lastCell = Range("A1")
And that's all!
 
Old August 21st, 2009, 08:31 AM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thank You

Thank You so much. It worked great!!!!!!!!! You are a STAR!
 
Old August 21st, 2009, 09:11 AM
Authorized User
 
Join Date: Mar 2008
Location: , , Russia.
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via ICQ to sektor
Default

If you need to do something else with your "lot's of files", then just write on sektor81@mail.ru




Similar Threads
Thread Thread Starter Forum Replies Last Post
Select row in GridView WITHOUT using Select button rao965 ASP.NET 2.0 Professional 1 February 15th, 2008 10:44 AM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
Open Word Doc from Access - find, find next save donaldmaloney Access VBA 1 May 25th, 2005 11:09 AM
Create a find and a find and replace in VB.NET snowy0 VB How-To 0 January 26th, 2004 07:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.