PC Review


Reply
Thread Tools Rate Thread

Copying diagonally opposite value from the known cell/range.

 
 
Marvin
Guest
Posts: n/a
 
      26th Aug 2010
Hello all,

The address of the cell that has the keyword I'm interested in, will
float when rows are added or deleted before its row. For example, if
the keyword is in cell B46, it will move to B48 when two rows are
added before the 46th row.

I have the following routine to find my keyword "Name of the person"
which currently resides in cell B46 in Sheet1.

Dim rng as Range
With Sheets("Sheet1").Range("A1:Z200")
Set rng = .Find(What:="Name of the person", _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With

I'm stuggling to accomplish the following, though.

Once the keyword is found, I want the macro/routine to find & copy the
value of the cell diagonally opposite to it in the left and paste the
value in cell Z2. In the context of the above example, cell diagonally
opposite in the left to B48 is A47. So, cell value of Z2 should be
equal to value of the cell A47 in this case.

How would I do that? Any help will be much appreciated.

Thanks.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      26th Aug 2010
Dim rng as Range
With Sheets("Sheet1").Range("A1:Z200")
Set rng = .Find(What:="Name of the person", _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With

if rng is nothing then
msgbox "Not found"
else
if rng.column = 1 _
or rng.row = 1 then
msgbox "No cell above or to the left!"
else
sheets("Sheet1").range("z2").value = rng.offset(-1,-1).value
end if
end if


(Untested, uncompiled. Watch for typos!)

On 08/26/2010 07:24, Marvin wrote:
> Hello all,
>
> The address of the cell that has the keyword I'm interested in, will
> float when rows are added or deleted before its row. For example, if
> the keyword is in cell B46, it will move to B48 when two rows are
> added before the 46th row.
>
> I have the following routine to find my keyword "Name of the person"
> which currently resides in cell B46 in Sheet1.
>
> Dim rng as Range
> With Sheets("Sheet1").Range("A1:Z200")
> Set rng = .Find(What:="Name of the person", _
> After:=.Cells(.Cells.Count), _
> LookIn:=xlValues, _
> LookAt:=xlWhole, _
> SearchOrder:=xlByRows, _
> SearchDirection:=xlNext, _
> MatchCase:=False)
> End With
>
> I'm stuggling to accomplish the following, though.
>
> Once the keyword is found, I want the macro/routine to find& copy the
> value of the cell diagonally opposite to it in the left and paste the
> value in cell Z2. In the context of the above example, cell diagonally
> opposite in the left to B48 is A47. So, cell value of Z2 should be
> equal to value of the cell A47 in this case.
>
> How would I do that? Any help will be much appreciated.
>
> Thanks.


--
Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to split a cell diagonally? Bruce Microsoft Excel Misc 2 9th Apr 2010 06:29 PM
Return Value in Cell Diagonally opposite Pete Microsoft Excel New Users 1 27th Nov 2009 09:43 PM
split a cell diagonally in excell - a calendar -2 dates in 1 cell =?Utf-8?B?dmlja2k=?= Microsoft Excel Misc 1 31st Oct 2006 02:40 PM
How do I divide a cell into two diagonally? =?Utf-8?B?Q2luZHk=?= Microsoft Excel Misc 2 4th Apr 2006 08:34 AM
copying dynamic range based on cell outside of range xcelelder Microsoft Excel Programming 3 29th Sep 2005 05:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:54 AM.