Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Paste and display issue

My code below does exactly what I need it to do. My only issue is that if
it is pasting the data way down on the sheet, the user has to scroll down to
find if. Any way to have the newly pasted data display after it is pasted?



Sub Paste_Data()

Dim BCell, NBCell
Dim PasteTo As Range
Dim rng

On Error GoTo Done

Range("B5").Select

Application.ScreenUpdating = False
Application.EnableEvents = False

For i = 1 To 65536
If ActiveCell.Value = Empty Then
BCell = "B" & CStr(i - 1)
NBCell = "B" & CStr(i - 2)

GoTo Finished

Else
Range("B" & CStr(i + 1)).Select
End If
Next i


Finished:

Application.EnableEvents = True

Set rng = Cells(ActiveCell.Row, 1)
rng(1, 2).Select

Selection.PasteSpecial Paste:=xlPasteValues

Application.EnableEvents = True

Done:

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Paste and display issue

Patrick,

I know you say your code does exactly what you want, but it contains unused
variables, undeclared variables, and doesn't turn ScreenUpdating back on.
Further, if you have an error you won't turn EnableEvents back on either.

I think what you are doing is pasting data at the next empty cell in column
B. To do this and to eliminate some of the issues above, I took the liberty
of rewriting your code. It also puts the last first pasted cell in the
upper left area of the screen

Sub Paste_Data()
Dim lngLastRow As Long

On Error GoTo Error_handler
Application.ScreenUpdating = False
Application.EnableEvents = False
lngLastRow = Range("B" & Rows.Count).End(xlUp).Row
Range("B" & lngLastRow + 1).PasteSpecial Paste:=xlPasteValues
Application.Goto reference:=Range("A" & lngLastRow), scroll:=True

Error_handler:
Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub

"Patrick C. Simonds" wrote in message
...
My code below does exactly what I need it to do. My only issue is that if
it is pasting the data way down on the sheet, the user has to scroll down
to find if. Any way to have the newly pasted data display after it is
pasted?



Sub Paste_Data()

Dim BCell, NBCell
Dim PasteTo As Range
Dim rng

On Error GoTo Done

Range("B5").Select

Application.ScreenUpdating = False
Application.EnableEvents = False

For i = 1 To 65536
If ActiveCell.Value = Empty Then
BCell = "B" & CStr(i - 1)
NBCell = "B" & CStr(i - 2)

GoTo Finished

Else
Range("B" & CStr(i + 1)).Select
End If
Next i


Finished:

Application.EnableEvents = True

Set rng = Cells(ActiveCell.Row, 1)
rng(1, 2).Select

Selection.PasteSpecial Paste:=xlPasteValues

Application.EnableEvents = True

Done:

End Sub

__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4380 (20090829) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




__________ Information from ESET NOD32 Antivirus, version of virus signature database 4380 (20090829) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Paste and display issue

Thank you

"Doug Glancy" wrote in message
...
Patrick,

I know you say your code does exactly what you want, but it contains
unused variables, undeclared variables, and doesn't turn ScreenUpdating
back on. Further, if you have an error you won't turn EnableEvents back on
either.

I think what you are doing is pasting data at the next empty cell in
column B. To do this and to eliminate some of the issues above, I took
the liberty of rewriting your code. It also puts the last first pasted
cell in the upper left area of the screen

Sub Paste_Data()
Dim lngLastRow As Long

On Error GoTo Error_handler
Application.ScreenUpdating = False
Application.EnableEvents = False
lngLastRow = Range("B" & Rows.Count).End(xlUp).Row
Range("B" & lngLastRow + 1).PasteSpecial Paste:=xlPasteValues
Application.Goto reference:=Range("A" & lngLastRow), scroll:=True

Error_handler:
Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub

"Patrick C. Simonds" wrote in message
...
My code below does exactly what I need it to do. My only issue is that
if it is pasting the data way down on the sheet, the user has to scroll
down to find if. Any way to have the newly pasted data display after it
is pasted?



Sub Paste_Data()

Dim BCell, NBCell
Dim PasteTo As Range
Dim rng

On Error GoTo Done

Range("B5").Select

Application.ScreenUpdating = False
Application.EnableEvents = False

For i = 1 To 65536
If ActiveCell.Value = Empty Then
BCell = "B" & CStr(i - 1)
NBCell = "B" & CStr(i - 2)

GoTo Finished

Else
Range("B" & CStr(i + 1)).Select
End If
Next i


Finished:

Application.EnableEvents = True

Set rng = Cells(ActiveCell.Row, 1)
rng(1, 2).Select

Selection.PasteSpecial Paste:=xlPasteValues

Application.EnableEvents = True

Done:

End Sub

__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4380 (20090829) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4380 (20090829) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



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
Display Issue Going Crazy for Graphics Excel Discussion (Misc queries) 3 January 28th 09 05:44 PM
Control button display issue Mike[_123_] Excel Programming 3 July 28th 08 03:36 PM
Display issue bluenoser1946 Excel Worksheet Functions 5 August 7th 05 06:15 PM
ActiveX Controls Display Issue? [email protected] Excel Discussion (Misc queries) 0 March 5th 05 05:43 PM
Calendar Control - Display Issue AG[_5_] Excel Programming 0 November 10th 04 08:42 PM


All times are GMT +1. The time now is 12:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"