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

The below works - but is there a better way? It seems that I had to add the
..select to make it work regardless on sheet was previously active - then I
forced another worksheet to be active.

Sub AddNewWeek()
Dim LastRow As Long
shtGraphData.Select
With Sheets("Graph_Data")
If Range("Z6").Value Range("Z5").Value Then
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
.Cells(LastRow + 1, "K").Value = Range("Z6").Value
.Cells(LastRow, "L").Resize(1, 6).Copy .Cells(LastRow + 1, "L")
End If
End With
shtInput.Select
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Removie .select

You were missing the . in front of your Range

Sub AddNewWeek()
Dim LastRow As Long
With Sheets("Graph_Data")
If .Range("Z6").Value .Range("Z5").Value Then
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
.Cells(LastRow + 1, "K").Value = .Range("Z6").Value
.Cells(LastRow, "L").Resize(1, 6).Copy .Cells(LastRow + 1, "L")
End If
End With
End Sub


"Brad" wrote:

The below works - but is there a better way? It seems that I had to add the
.select to make it work regardless on sheet was previously active - then I
forced another worksheet to be active.

Sub AddNewWeek()
Dim LastRow As Long
shtGraphData.Select
With Sheets("Graph_Data")
If Range("Z6").Value Range("Z5").Value Then
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
.Cells(LastRow + 1, "K").Value = Range("Z6").Value
.Cells(LastRow, "L").Resize(1, 6).Copy .Cells(LastRow + 1, "L")
End If
End With
shtInput.Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Removie .select

Brad schrieb:
The below works - but is there a better way? It seems that I had to add the
.select to make it work regardless on sheet was previously active - then I
forced another worksheet to be active.

Sub AddNewWeek()
Dim LastRow As Long
shtGraphData.Select
With Sheets("Graph_Data")
If Range("Z6").Value Range("Z5").Value Then
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
.Cells(LastRow + 1, "K").Value = Range("Z6").Value
.Cells(LastRow, "L").Resize(1, 6).Copy .Cells(LastRow + 1, "L")
End If
End With
shtInput.Select
End Sub


Brad,

if Range("Z6") and Range("Z5") are on shtGraphData, you need to add a
dot before the Range:

If .Range("Z6").Value .Range("Z5").Value Then

same he
Cells(LastRow + 1, "K").Value = .Range("Z6").Value

Then no selection should be necessary.

Regards,
xlDominik.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Removie .select

Aaaarrrrggh (missing a period). I will check this tomorrow - but that makes
sense

Thank you, very much!!!!


"Sam Wilson" wrote:

You were missing the . in front of your Range

Sub AddNewWeek()
Dim LastRow As Long
With Sheets("Graph_Data")
If .Range("Z6").Value .Range("Z5").Value Then
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
.Cells(LastRow + 1, "K").Value = .Range("Z6").Value
.Cells(LastRow, "L").Resize(1, 6).Copy .Cells(LastRow + 1, "L")
End If
End With
End Sub


"Brad" wrote:

The below works - but is there a better way? It seems that I had to add the
.select to make it work regardless on sheet was previously active - then I
forced another worksheet to be active.

Sub AddNewWeek()
Dim LastRow As Long
shtGraphData.Select
With Sheets("Graph_Data")
If Range("Z6").Value Range("Z5").Value Then
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
.Cells(LastRow + 1, "K").Value = Range("Z6").Value
.Cells(LastRow, "L").Resize(1, 6).Copy .Cells(LastRow + 1, "L")
End If
End With
shtInput.Select
End Sub

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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
error - select method failed - (columns.select) PBcorn Excel Programming 3 May 19th 08 10:49 AM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 4th 05 11:59 PM


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