Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Lookup and Select Row

I have a problem that I just can't seem to get my mind around. I know this should be easy, but I just don't what to use

The code I have pulls lots of data out of workbooks and consolidates it into several others. What I need it something that will for instance, look in column "A" for one for a value (this value is variable). If the value exists then select that row and set that row value to the variable "PasteRow". If the value doesn't exist in the row then select the last row + 1 and set this as the "PasteRow"

Basically I need to have something automatically replace data if it has been updated and if not then add the new data. If the variable value exists in the first column then the data has been updated, so select the row and then 'do stuff' and then continue on to the next set of data. If the value doesn't exist then this is new data and paste it to the bottom

I know this can be done, and I have learned alot in the last year or so, esp. with the help of this newsgroup. I just need to get some direction on this, as I can't figure it out

Thanks for you time and effor

Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Lookup and Select Row

Try this
Sub GetRow(Val As String
Dim PasteRange As Range, cnt As Singl
'On Error Resume Nex
Set x = Cells.Find(Val
If x Is Nothing The
cnt = ActiveSheet.UsedRange.Rows.Count +
Set PasteRange = Rows(cnt
Exit Su
End I
Set PasteRange = Range(x.Address).EntireRo
Set x = Nothin
End Sub
----- James Stephens wrote: ----

I have a problem that I just can't seem to get my mind around. I know this should be easy, but I just don't what to use

The code I have pulls lots of data out of workbooks and consolidates it into several others. What I need it something that will for instance, look in column "A" for one for a value (this value is variable). If the value exists then select that row and set that row value to the variable "PasteRow". If the value doesn't exist in the row then select the last row + 1 and set this as the "PasteRow"

Basically I need to have something automatically replace data if it has been updated and if not then add the new data. If the variable value exists in the first column then the data has been updated, so select the row and then 'do stuff' and then continue on to the next set of data. If the value doesn't exist then this is new data and paste it to the bottom

I know this can be done, and I have learned alot in the last year or so, esp. with the help of this newsgroup. I just need to get some direction on this, as I can't figure it out

Thanks for you time and effor

Jim
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Lookup and Select Row

This looks like it almost works, I tried it out and I have a couple of questions

Now how do I select which column I want this to search in
Do I just start it with - columns("A:A").Selec

Also when I try to use the "PasteRange", I have an error. I use this "PasteRange", value for other formulas, such as - Range("B" & PasteRange).Select and then do stuff. Is there a way to set this paste range as just the row number and not an actual cell value, I think that is the problem I am running into, however I am not sure

Thanks for your help

Ji

----- chris wrote: ----

Try this
Sub GetRow(Val As String
Dim PasteRange As Range, cnt As Singl
'On Error Resume Nex
Set x = Cells.Find(Val
If x Is Nothing The
cnt = ActiveSheet.UsedRange.Rows.Count +
Set PasteRange = Rows(cnt
Exit Su
End I
Set PasteRange = Range(x.Address).EntireRo
Set x = Nothin
End Sub
----- James Stephens wrote: ----

I have a problem that I just can't seem to get my mind around. I know this should be easy, but I just don't what to use

The code I have pulls lots of data out of workbooks and consolidates it into several others. What I need it something that will for instance, look in column "A" for one for a value (this value is variable). If the value exists then select that row and set that row value to the variable "PasteRow". If the value doesn't exist in the row then select the last row + 1 and set this as the "PasteRow"

Basically I need to have something automatically replace data if it has been updated and if not then add the new data. If the variable value exists in the first column then the data has been updated, so select the row and then 'do stuff' and then continue on to the next set of data. If the value doesn't exist then this is new data and paste it to the bottom

I know this can be done, and I have learned alot in the last year or so, esp. with the help of this newsgroup. I just need to get some direction on this, as I can't figure it out

Thanks for you time and effor

Jim
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
LOOKUP help....select like names and enter sales pm Excel Discussion (Misc queries) 1 November 4th 09 07:51 PM
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
Select other workbook to select data in a macro. T Tromp Excel Programming 2 September 19th 03 01:43 PM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"