Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default finding last column from a target row

Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right of
row2?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 174
Default finding last column from a target row

Thomas,

You probably defined an object "newtargcell" but you are calling "targcell"

Try ...
Set newtargcell = range("A2")..End(xlRight)

Could you check already my feedback on previous question?

Wkr,

JP

"thomas donino" wrote in message
...
Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right of
row2?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default finding last column from a target row

What is targCell ?

row2 or Column 2 ?
--
Jim Cone
Portland, Oregon USA



"thomas donino"

wrote in message
...
Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right of row2?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default finding last column from a target row

Sub testcol()
Set newtargCell = Range("A2")
Set newtargCell = newtargCell.End(xlRight)
Lastcolumn = newtargCell
MsgBox "Last column is" & newtargCell
End Sub

is the correct code, but doesn't work

"Jim Cone" wrote:

What is targCell ?

row2 or Column 2 ?
--
Jim Cone
Portland, Oregon USA



"thomas donino"

wrote in message
...
Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right of row2?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 174
Default finding last column from a target row

Lastcolumn = newtargCell.column

"thomas donino" wrote in message
...
Sub testcol()
Set newtargCell = Range("A2")
Set newtargCell = newtargCell.End(xlRight)
Lastcolumn = newtargCell
MsgBox "Last column is" & newtargCell
End Sub

is the correct code, but doesn't work

"Jim Cone" wrote:

What is targCell ?

row2 or Column 2 ?
--
Jim Cone
Portland, Oregon USA



"thomas donino"

wrote in message
...
Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right
of row2?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default finding last column from a target row


Lastcolumn = newtargCell


This sets Lastcolumn to the VALUE of newtargCell, NOT the column
number of that cell. Try

Lastcolumn = newtargCell.Column

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sun, 16 Aug 2009 09:55:01 -0700, thomas donino
wrote:

Sub testcol()
Set newtargCell = Range("A2")
Set newtargCell = newtargCell.End(xlRight)
Lastcolumn = newtargCell
MsgBox "Last column is" & newtargCell
End Sub

is the correct code, but doesn't work

"Jim Cone" wrote:

What is targCell ?

row2 or Column 2 ?
--
Jim Cone
Portland, Oregon USA



"thomas donino"

wrote in message
...
Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right of row2?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default finding last column from a target row

You also need to change...

xlRight to xlToRight
--
Jim Cone
Portland, Oregon USA



"thomas donino"
wrote in message
...
Sub testcol()
Set newtargCell = Range("A2")
Set newtargCell = newtargCell.End(xlRight)
Lastcolumn = newtargCell
MsgBox "Last column is" & newtargCell
End Sub

is the correct code, but doesn't work




"Jim Cone" wrote:
What is targCell ?

row2 or Column 2 ?
--
Jim Cone
Portland, Oregon USA




"thomas donino"

wrote in message
...
Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right of row2?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default finding last column from a target row

All fixed, thank you all for the help

"Jim Cone" wrote:

You also need to change...

xlRight to xlToRight
--
Jim Cone
Portland, Oregon USA



"thomas donino"
wrote in message
...
Sub testcol()
Set newtargCell = Range("A2")
Set newtargCell = newtargCell.End(xlRight)
Lastcolumn = newtargCell
MsgBox "Last column is" & newtargCell
End Sub

is the correct code, but doesn't work




"Jim Cone" wrote:
What is targCell ?

row2 or Column 2 ?
--
Jim Cone
Portland, Oregon USA




"thomas donino"

wrote in message
...
Set newtargcell = Range("A2")
Set newtargcell = targCell.End(xlRight)

the last produces an error, shouldnt it find the last cell to the right of row2?


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
selectin the whole column beside the target cell NDBC Excel Programming 4 July 25th 09 03:19 PM
Column Chart with Dynamix Target Zones Tfrup12 Charts and Charting in Excel 1 March 3rd 09 05:33 PM
Target line to a column chart? Deb Charts and Charting in Excel 2 September 14th 07 12:50 PM
Target cell reference moves when target is cut and pasted Illya Teideman Excel Discussion (Misc queries) 5 May 31st 07 11:34 AM
assigning formula to a target column Alex Excel Programming 1 August 30th 05 07:19 PM


All times are GMT +1. The time now is 06:46 AM.

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"