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

here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Select problem

You are using range objects so you need to use set and different properties...

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
set lastRow = Cells(Rows.Count, "A").End(xlUp).offset(1,0)
set A = lastRow 'not sure why you are doing this...
A.Select
End Sub

--
HTH...

Jim Thomlinson


"Mark J" wrote:

here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Select problem

The calculated value for LastRow is not a range; rather it is a number (the
..Row property reference and the +1 make that the case). You probably want
something like this...

Private Sub Workbook_Open()
Cells(Rows.Count, "A").End(xlUp).Offset(1).Select
End Sub

--
Rick (MVP - Excel)


"Mark J" wrote in message
...
here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Select problem

Thank you, and will this always go to the first blank row?

"Jim Thomlinson" wrote:

You are using range objects so you need to use set and different properties...

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
set lastRow = Cells(Rows.Count, "A").End(xlUp).offset(1,0)
set A = lastRow 'not sure why you are doing this...
A.Select
End Sub

--
HTH...

Jim Thomlinson


"Mark J" wrote:

here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Select problem

No, not the FIRST blank row; rather, it goes to the the first blank row
AFTER the last data cell (the distinction matters if you have blank cells
WITHIN your data).

--
Rick (MVP - Excel)


"Mark J" wrote in message
...
Thank you, and will this always go to the first blank row?

"Jim Thomlinson" wrote:

You are using range objects so you need to use set and different
properties...

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
set lastRow = Cells(Rows.Count, "A").End(xlUp).offset(1,0)
set A = lastRow 'not sure why you are doing this...
A.Select
End Sub

--
HTH...

Jim Thomlinson


"Mark J" wrote:

here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Select problem

with this redone;
Dim lastRow As Range
Dim A As Range
Dim rng1 As Long
Dim rng As Range

Private Sub Workbook_Open()

Set lastRow = Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
lastRow.Select

WBname = " " & Format(Now() - 1, "mmddyyyy") & ".xls"
Workbooks.Open "C:\LIMS\WaterQuality_Export-daily" & WBname
Set rng = Range("A1:Q500")
rng.Copy

'code to paste data into sheet(2)

End Sub

how would i code it to paste the data into sheet(2)?



"Rick Rothstein" wrote:

The calculated value for LastRow is not a range; rather it is a number (the
..Row property reference and the +1 make that the case). You probably want
something like this...

Private Sub Workbook_Open()
Cells(Rows.Count, "A").End(xlUp).Offset(1).Select
End Sub

--
Rick (MVP - Excel)


"Mark J" wrote in message
...
here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Select problem

What this code does is it looks at teh currently active sheet and it goes to
the first blank row in column A of that sheet. If you wnated a specific sheet
then...

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
set lastRow = sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).offset(1,0)
set A = lastRow 'not sure why you are doing this...
A.parent.select 'Select the sheet
A.Select
End Sub

--
HTH...

Jim Thomlinson


"Mark J" wrote:

Thank you, and will this always go to the first blank row?

"Jim Thomlinson" wrote:

You are using range objects so you need to use set and different properties...

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
set lastRow = Cells(Rows.Count, "A").End(xlUp).offset(1,0)
set A = lastRow 'not sure why you are doing this...
A.Select
End Sub

--
HTH...

Jim Thomlinson


"Mark J" wrote:

here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Select problem

Mark,

Yor going OTT with set now, you don't need them

Set rng = Range("A1:Q500")
rng.Copy

Becomes

range("A1:Q500").copy
sheets("Sheet2").range("A1").pastespecial
Application.cutcopymode=false

Mike

"Mark J" wrote:

with this redone;
Dim lastRow As Range
Dim A As Range
Dim rng1 As Long
Dim rng As Range

Private Sub Workbook_Open()

Set lastRow = Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
lastRow.Select

WBname = " " & Format(Now() - 1, "mmddyyyy") & ".xls"
Workbooks.Open "C:\LIMS\WaterQuality_Export-daily" & WBname
Set rng = Range("A1:Q500")
rng.Copy

'code to paste data into sheet(2)

End Sub

how would i code it to paste the data into sheet(2)?



"Rick Rothstein" wrote:

The calculated value for LastRow is not a range; rather it is a number (the
..Row property reference and the +1 make that the case). You probably want
something like this...

Private Sub Workbook_Open()
Cells(Rows.Count, "A").End(xlUp).Offset(1).Select
End Sub

--
Rick (MVP - Excel)


"Mark J" wrote in message
...
here is my code;

Dim lastRow As Range
Dim A As Range

Private Sub Workbook_Open()
lastRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
A = lastRow
A.Select
End Sub

can someone tell me what i need to fix to make this work.thanks



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
SpecialCells Select problem G Lykos Excel Programming 12 October 10th 07 02:11 AM
Problem with Select Case construct? Chris Bromley[_2_] Excel Programming 1 April 12th 05 08:27 PM
Very simple Select problem? Kobayashi[_24_] Excel Programming 6 November 27th 03 10:10 PM
Problem With Select Case Steve[_27_] Excel Programming 18 August 6th 03 09:28 PM
Select Range problem Marcus Excel Programming 2 July 9th 03 12:47 PM


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