Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Bob
 
Posts: n/a
Default Extra added to a script

In the A Column I would like the date to be entered as well?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$E$162" Then
With Sheets("ChequesOut")
If .[C1] = "" Then
Union([B162], [E162]).Copy .[C1]
Else
Union([B162], [E162]).Copy .Range("C" & Rows.Count). _
End(xlUp)(2)
End If
[B162].Select
End With
End If
End Sub


Thanks in advance.........Bob Vance


  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Using [C1] is slower than using Range("C1") and for me, I find it more difficult
to read.

But something like this might work ok:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NextRow As Long
If Target.Address = "$E$162" Then

With Sheets("ChequesOut")

If .Range("C1").Value = "" Then
NextRow = 1
Else
NextRow = .Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Row
End If

Me.Range("b162,E162").Copy _
Destination:=.Cells(NextRow, "C")

With .Cells(NextRow, "A")
.Value = Now 'date ???
.NumberFormat = "mm/dd/yyyy hh:mm:ss" 'mm/dd/yyyy ????
End With

End With

Me.Range("B162").Select
End If
End Sub

Bob wrote:

In the A Column I would like the date to be entered as well?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$E$162" Then
With Sheets("ChequesOut")
If .[C1] = "" Then
Union([B162], [E162]).Copy .[C1]
Else
Union([B162], [E162]).Copy .Range("C" & Rows.Count). _
End(xlUp)(2)
End If
[B162].Select
End With
End If
End Sub

Thanks in advance.........Bob Vance


--

Dave Peterson
  #3   Report Post  
Bob
 
Posts: n/a
Default

Brilliant Thank You Dave :)

"Dave Peterson" wrote in message
...
Using [C1] is slower than using Range("C1") and for me, I find it more
difficult
to read.

But something like this might work ok:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NextRow As Long
If Target.Address = "$E$162" Then

With Sheets("ChequesOut")

If .Range("C1").Value = "" Then
NextRow = 1
Else
NextRow = .Range("C" & Rows.Count).End(xlUp).Offset(1,
0).Row
End If

Me.Range("b162,E162").Copy _
Destination:=.Cells(NextRow, "C")

With .Cells(NextRow, "A")
.Value = Now 'date ???
.NumberFormat = "mm/dd/yyyy hh:mm:ss" 'mm/dd/yyyy ????
End With

End With

Me.Range("B162").Select
End If
End Sub

Bob wrote:

In the A Column I would like the date to be entered as well?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$E$162" Then
With Sheets("ChequesOut")
If .[C1] = "" Then
Union([B162], [E162]).Copy .[C1]
Else
Union([B162], [E162]).Copy .Range("C" & Rows.Count). _
End(xlUp)(2)
End If
[B162].Select
End With
End If
End Sub

Thanks in advance.........Bob Vance


--

Dave Peterson



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
OsCommerce - Easy Populate Script - CSV/TXT Conversion Problem. PriceTrim Excel Discussion (Misc queries) 3 July 5th 05 05:27 PM
VBA script help..Please !!!! Anthony Excel Discussion (Misc queries) 6 June 6th 05 01:40 PM
Using a VB Script for barcodes - new to this Jon Excel Discussion (Misc queries) 2 May 13th 05 02:42 PM
How to remove an extra line added by excel when pasting into notep CoolGuy Excel Discussion (Misc queries) 1 March 2nd 05 02:57 PM
Extra line space JJ Excel Discussion (Misc queries) 1 February 18th 05 11:32 PM


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