Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Selecting Cells Dynamically in Different Rows

Hi Everyone,

I have started programming in Excel VB about a month ago. I guess I'm
doing well but Now I have a problem at hand.

My Macro runs in a loop and searches for multiple entries one by
one ... and needs to copy the required fields corresponding to that
Entry to another sheet.

The first column in my Sheet contains the reference Entries.

I search the Entire first column for that entry and if I find it then
I need to copy SOME of the cells of that Row to another Sheet.

I can get the number of that Row by ActiveCell.Row ... and I know
which colums of that Row I need to Copy.

But I DONT know how to use both of these to Select the Required
Cell ?????

Kindly guide me ... I will be really grateful for your help.

Thanks and Best Regards,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Selecting Cells Dynamically in Different Rows

On 28 Apr, 08:51, wrote:
Hi Everyone,

I have started programming in Excel VB about a month ago. I guess I'm
doing well but Now I have a problem at hand.

My Macro runs in a loop and searches for multiple entries one by
one ... and needs to copy the required fields corresponding to that
Entry to another sheet.

The first column in my Sheet contains the reference Entries.

I search the Entire first column for that entry and if I find it then
I need to copy SOME of the cells of that Row to another Sheet.

I can get the number of that Row by ActiveCell.Row ... and I know
which colums of that Row I need to Copy.

But I DONT know how to use both of these to Select the Required
Cell ?????

Kindly guide me ... I will be really grateful for your help.

Thanks and Best Regards,


Are you trying to find a list of unique entries?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Selecting Cells Dynamically in Different Rows

Copy from Sheet1 to Sheet2 in next empty row

Sub FindAndCopy()
For rw = 1 To 100
If Sheets("Sheet1").Cells(rw, 1) = "What im looking at" Then
Sheets("Sheet1").Range("B" & rw).Copy Sheets("Sheet2").Range("A" &
Cells(65535, "A").End(xlUp).Row + 1)
Sheets("Sheet1").Range("D" & rw).Copy Sheets("Sheet2").Range("B" &
Cells(65535, "B").End(xlUp).Row + 1)
Sheets("Sheet1").Range("F" & rw).Copy Sheets("Sheet2").Range("E" &
Cells(65535, "E").End(xlUp).Row + 1)
End If
Next
End Sub


"Dave Mac" skrev:

On 28 Apr, 08:51, wrote:
Hi Everyone,

I have started programming in Excel VB about a month ago. I guess I'm
doing well but Now I have a problem at hand.

My Macro runs in a loop and searches for multiple entries one by
one ... and needs to copy the required fields corresponding to that
Entry to another sheet.

The first column in my Sheet contains the reference Entries.

I search the Entire first column for that entry and if I find it then
I need to copy SOME of the cells of that Row to another Sheet.

I can get the number of that Row by ActiveCell.Row ... and I know
which colums of that Row I need to Copy.

But I DONT know how to use both of these to Select the Required
Cell ?????

Kindly guide me ... I will be really grateful for your help.

Thanks and Best Regards,


Are you trying to find a list of unique entries?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Selecting Cells Dynamically in Different Rows

No Dave ... im NOT trying to find unique entries.
And thanks Excellent for the help ....

My question is that:

Suppose I find my required data in Row 10. And i know that in Row 10 ,
I need to copy the Entries of Column F and Column R. ( which means
Cells F10 and R10)

How will i Select these Cells? Logically I could use

my_row = ActiveCell.Row
and then use Cells( "F" & my_row)
But this does not work.
Please tell me what do i need to write here. I think im only lacking
the correct syntax.

thanks a lot both of you...

Looking forward to your further guidance

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Selecting Cells Dynamically in Different Rows

if i got ur right then try :

Sub FindAndCopy()
For rw = 1 To 100
If Sheets("Sheet1").Cells(rw, 1) = "What im looking at" Then
Sheets("Sheet1").Range("F" & rw).Copy Sheets("Sheet2").Range("A" &
Cells(65535, "A").End(xlUp).Row + 1) 'copy to colA
Sheets("Sheet1").Range("R" & rw).Copy Sheets("Sheet2").Range("B" &
Cells(65535, "B").End(xlUp).Row + 1) 'copy to colB
End If
Next
End Sub


" skrev:

No Dave ... im NOT trying to find unique entries.
And thanks Excellent for the help ....

My question is that:

Suppose I find my required data in Row 10. And i know that in Row 10 ,
I need to copy the Entries of Column F and Column R. ( which means
Cells F10 and R10)

How will i Select these Cells? Logically I could use

my_row = ActiveCell.Row
and then use Cells( "F" & my_row)
But this does not work.
Please tell me what do i need to write here. I think im only lacking
the correct syntax.

thanks a lot both of you...

Looking forward to your further guidance




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting Cells Dynamically in Different Rows

Here are a few ways to address that range:

with activesheet

.cells(my_row,"F").copy _
destination:=....

.cells(my_row,"R").copy _
destination:=....

or
.Range("F" & my_row).copy _
destination:=....

.Range("R" & my_row).copy _
destination:=....

If you wanted to copy all the cells from F:R in my_Row, you could use:

.range(.cells(my_row,"F"),.cells(my_row,"R")).copy _
destination:=....

or
.cells(my_Row,"F").resize(1,13).copy _
destination:=....

or
.range("F" & my_Row).resize(1,13).copy _
destination:=....

end with


wrote:

No Dave ... im NOT trying to find unique entries.
And thanks Excellent for the help ....

My question is that:

Suppose I find my required data in Row 10. And i know that in Row 10 ,
I need to copy the Entries of Column F and Column R. ( which means
Cells F10 and R10)

How will i Select these Cells? Logically I could use

my_row = ActiveCell.Row
and then use Cells( "F" & my_row)
But this does not work.
Please tell me what do i need to write here. I think im only lacking
the correct syntax.

thanks a lot both of you...

Looking forward to your further guidance


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Selecting Cells Dynamically in Different Rows

Thanks a LOT Excelent...

Half of my problem is solved. By Looking at your example I found out
the way to select required cell in my required row.

------------- Code -------------------------------
my_row = ActiveCell.Row
Range("F" & my_row).Select
------------------------------------------------------
Works fine !!

Now for the other half...

Kindly tell me what should i do if I know the COLUMN and want to go to
a required Row ???

I have tried the following code but it does not work.

---------------------- Code ----------------------
my_col = ActiveCell.Column
Range( my_col & 19).Select
------------------------------------------------------

Perhaps this is because in this case the value stored in My_Col is not
the 'name' of the column ( like A , B or C) but the 'Number' of the
column ( i.e. 1, 2 or 3 instead of A , B or C).

Kindly guide me what to do ??

Thanks a lot for ure valuable help !





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Selecting Cells Dynamically in Different Rows

try
my_col = ActiveCell.Column
Cells(19, my_col).Select


" skrev:

Thanks a LOT Excelent...

Half of my problem is solved. By Looking at your example I found out
the way to select required cell in my required row.

------------- Code -------------------------------
my_row = ActiveCell.Row
Range("F" & my_row).Select
------------------------------------------------------
Works fine !!

Now for the other half...

Kindly tell me what should i do if I know the COLUMN and want to go to
a required Row ???

I have tried the following code but it does not work.

---------------------- Code ----------------------
my_col = ActiveCell.Column
Range( my_col & 19).Select
------------------------------------------------------

Perhaps this is because in this case the value stored in My_Col is not
the 'name' of the column ( like A , B or C) but the 'Number' of the
column ( i.e. 1, 2 or 3 instead of A , B or C).

Kindly guide me what to do ??

Thanks a lot for ure valuable help !






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Selecting Cells Dynamically in Different Rows

or:
Range(Chr(my_col + 64) & 19).Select

"excelent" skrev:

try
my_col = ActiveCell.Column
Cells(19, my_col).Select


" skrev:

Thanks a LOT Excelent...

Half of my problem is solved. By Looking at your example I found out
the way to select required cell in my required row.

------------- Code -------------------------------
my_row = ActiveCell.Row
Range("F" & my_row).Select
------------------------------------------------------
Works fine !!

Now for the other half...

Kindly tell me what should i do if I know the COLUMN and want to go to
a required Row ???

I have tried the following code but it does not work.

---------------------- Code ----------------------
my_col = ActiveCell.Column
Range( my_col & 19).Select
------------------------------------------------------

Perhaps this is because in this case the value stored in My_Col is not
the 'name' of the column ( like A , B or C) but the 'Number' of the
column ( i.e. 1, 2 or 3 instead of A , B or C).

Kindly guide me what to do ??

Thanks a lot for ure valuable help !






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
Selecting data from cells that are 5 rows apart and groung in 1 co Jorge Excel Worksheet Functions 6 January 16th 08 05:12 PM
after selecting 50 rows of a column i can't reference the cells in the rows Bob Salzer New Users to Excel 2 July 21st 06 10:29 PM
Selecting rows from cells sakk555 Excel Discussion (Misc queries) 4 June 5th 05 12:21 AM
selecting range of cells - variable # of rows [email protected] Excel Programming 6 April 15th 05 02:10 PM
Dynamically locating value; selecting that row and everything above (or below) and deleting/copying Steven Rosenberg[_2_] Excel Programming 14 February 29th 04 11:10 PM


All times are GMT +1. The time now is 01:56 PM.

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

About Us

"It's about Microsoft Excel"