#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default MACRO CODE

Hi, can anybody please tell that what should be the macro code if I
want to
select next cell of the last value in coloumn. like if i have values
in coloumn "A" then how can i select next cell of coloumn "A" cell
which have the last value.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default MACRO CODE

Hi
for column A
Cells(rows.Count,"A").End(xlUp).offset(1,0).Select

if you want the last cell in a block, but don't want to jump to a
second block in column A e.g. you have data in A2 to A10 and in A14 to
A20, but you just want the end of the A2 to A10 block then:

Range("A2").End(xldown).offset(1,0).select

regards
Paul

On Feb 25, 3:38*pm, K wrote:
Hi, can anybody please tell that what should be the macro code if I
want to
select next cell of the last value in coloumn. like if i have values
in coloumn "A" then how can i select next cell of coloumn "A" cell
which have the last value.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default MACRO CODE

On Feb 25, 3:44*pm, wrote:
Hi
for column A
Cells(rows.Count,"A").End(xlUp).offset(1,0).Select

if you want the last cell in a block, but don't want to jump to a
second block in column A e.g. you have data in A2 to A10 and in A14 to
A20, but you just want the end of the A2 to A10 block then:

Range("A2").End(xldown).offset(1,0).select

regards
Paul

On Feb 25, 3:38*pm, K wrote:



Hi, can anybody please tell that what should be the macro code if I
want to
select next cell of the last value in coloumn. like if i have values
in coloumn "A" then how can i select next cell of coloumn "A" cell
which have the last value.- Hide quoted text -


- Show quoted text -


thanks paul
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default MACRO CODE

On Feb 25, 3:44*pm, wrote:
Hi
for column A
Cells(rows.Count,"A").End(xlUp).offset(1,0).Select

if you want the last cell in a block, but don't want to jump to a
second block in column A e.g. you have data in A2 to A10 and in A14 to
A20, but you just want the end of the A2 to A10 block then:

Range("A2").End(xldown).offset(1,0).select

regards
Paul

On Feb 25, 3:38*pm, K wrote:



Hi, can anybody please tell that what should be the macro code if I
want to
select next cell of the last value in coloumn. like if i have values
in coloumn "A" then how can i select next cell of coloumn "A" cell
which have the last value.- Hide quoted text -


- Show quoted text -


Hi paul, i asked the above question so i can amend my macro. Please
see my macro below as its not working. can you please tell that what
wrong i am doing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastRow As Long
Dim StartRow As Long
Dim slc As Long
slc = Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Select
If slc < "" Then
StartRow = Cells(Rows.Count, 2).End(xlUp).Row - 1
Cells(StartRow + 1, 1).Resize(6, 1).EntireRow.Insert
For i = 1 To 6
Cells(StartRow + i, 9).Resize(1, 6).Merge
Next i
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
Application.ScreenUpdating = False
With Range(Cells(StartRow, 2), Cells(LastRow, 2))
.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
End With
Application.ScreenUpdating = True
End If
End Sub
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default MACRO CODE

Hi
As written, slc is a range not a long
Avoid the select and do
slc = Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Value

If you need the select for something else later then do

Dim myRange as Range
myRange = Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Select
slc = Selection.Value

regards
Paul

On Feb 25, 3:56*pm, K wrote:
On Feb 25, 3:44*pm, wrote:





Hi
for column A
Cells(rows.Count,"A").End(xlUp).offset(1,0).Select


if you want the last cell in a block, but don't want to jump to a
second block in column A e.g. you have data in A2 to A10 and in A14 to
A20, but you just want the end of the A2 to A10 block then:


Range("A2").End(xldown).offset(1,0).select


regards
Paul


On Feb 25, 3:38*pm, K wrote:


Hi, can anybody please tell that what should be the macro code if I
want to
select next cell of the last value in coloumn. like if i have values
in coloumn "A" then how can i select next cell of coloumn "A" cell
which have the last value.- Hide quoted text -


- Show quoted text -


Hi paul, i asked the above question so i can amend my macro. *Please
see my macro below as its not working. can you please tell that what
wrong i am doing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastRow As Long
Dim StartRow As Long
Dim slc As Long
slc = Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Select
If slc < "" Then
StartRow = Cells(Rows.Count, 2).End(xlUp).Row - 1
Cells(StartRow + 1, 1).Resize(6, 1).EntireRow.Insert
For i = 1 To 6
Cells(StartRow + i, 9).Resize(1, 6).Merge
Next i
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
Application.ScreenUpdating = False
With Range(Cells(StartRow, 2), Cells(LastRow, 2))
.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
End With
Application.ScreenUpdating = True
End If
End Sub- Hide quoted text -

- Show quoted text -


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
Slow code when used as VBA code instead of macro (copying visible columns) [email protected] Excel Programming 3 April 2nd 07 05:26 PM
Can I use code/macro to change code/macro in an existing file? Scott Bedows Excel Programming 2 February 14th 07 05:50 AM
Macro code to remove a macro after it executes Charles Excel Programming 4 March 22nd 06 12:11 PM
read macro code by vb code Francesco Geri Excel Programming 2 October 7th 05 10:24 AM
do anybody have a sample code for executing excel macro from vb code?<eom B Deepak Excel Programming 2 September 30th 05 09:59 AM


All times are GMT +1. The time now is 04:30 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"