Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pasting Blanks using a macro


Hi,

I have a macro and a button setup to copy and paste a coupld column
and rows into another worksheet. The pasting material is differen
columns (name, date, amount spent, etc) with several rows for th
different information from each individual input. There are 30 rows i
total. The macro highlights all 30 rows then over 4 columns. I
copies the material, goes to the other worksheet with similar headings
finds the last entered row, and pastes the information into the sheet.


The problem is:
When the macro copies formulas that end up equaling "" (nothing there)
it copies something? but it doesnt appear anywhere when it is pasted
HOWEVER, when the macro goes to the last entered row, it takes i
account the blanks from the previous paste. How can I get rid o
these, so it pastes directly after the last REAL number, instead o
several "blanks"?

Does this make sense? I can send the sheet in order to show you wha
it looks like

--
TTomSawye
-----------------------------------------------------------------------
TTomSawyer's Profile: http://www.excelforum.com/member.php...fo&userid=2051
View this thread: http://www.excelforum.com/showthread.php?threadid=39594

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Pasting Blanks using a macro

Hi TTomSawyer,

In the absence of your code, perhaps data could be copied as values rather
than formulas.

If this is not a viable option, it would be necessary to evaluate the cell
which determines the last row on the target sheet, to determine if it
contains a formula which resolves to an empty string.

Post the button code and indicate if values may be copied to the target
sheet.


---
Regards,
Norman



"TTomSawyer" wrote
in message ...

Hi,

I have a macro and a button setup to copy and paste a coupld columns
and rows into another worksheet. The pasting material is different
columns (name, date, amount spent, etc) with several rows for the
different information from each individual input. There are 30 rows in
total. The macro highlights all 30 rows then over 4 columns. It
copies the material, goes to the other worksheet with similar headings,
finds the last entered row, and pastes the information into the sheet.


The problem is:
When the macro copies formulas that end up equaling "" (nothing there),
it copies something? but it doesnt appear anywhere when it is pasted.
HOWEVER, when the macro goes to the last entered row, it takes in
account the blanks from the previous paste. How can I get rid of
these, so it pastes directly after the last REAL number, instead of
several "blanks"?

Does this make sense? I can send the sheet in order to show you what
it looks like.


--
TTomSawyer
------------------------------------------------------------------------
TTomSawyer's Profile:
http://www.excelforum.com/member.php...o&userid=20511
View this thread: http://www.excelforum.com/showthread...hreadid=395945



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pasting Blanks using a macro


Alright,

So these are the functions that i am copying and pasting from:

=IF(D13="","","Cash")

So if the box d13 has somethign in it, it says cash, otherwise it does
nothing, sorta.

the macro for pasting from one sheet to the other is below:

ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("MASTER Pettycash and CC").Select
Range("B7").Select
Selection.End(xlDown).Select
Selection.End(xlToLeft).Select
Selection.Copy
Sheets("PETTY CASH INPUT").Select
Range("Y6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=False
Range("C154:K185").Select
Selection.Copy
Sheets("MASTER Pettycash and CC").Select
Range("B7").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=False
Range("B7").Select
Selection.End(xlDown).Select
Selection.End(xlToLeft).Select
Selection.Copy
Sheets("PETTY CASH INPUT").Select
Range("AA6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=False
ActiveWindow.ScrollColumn = 1
Range("B6:F37").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("C4").Select
Selection.ClearContents
Range("AA6").Select
End Sub


--
TTomSawyer
------------------------------------------------------------------------
TTomSawyer's Profile: http://www.excelforum.com/member.php...o&userid=20511
View this thread: http://www.excelforum.com/showthread...hreadid=395945

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Pasting Blanks using a macro

Hi TTomSawyer,

Try the following on a *copy* of your workbook:

'========================
Sub Tester()
Dim rng As Range
Dim rng2 As Range
Dim ws1 As Worksheet
Dim ws2 As Worksheet

Application.ScreenUpdating = False

Set ws1 = Sheets("MASTER Pettycash and CC")
Set ws2 = Sheets("PETTY CASH INPUT")

ws1.Range("B7", Range("B7"). _
End(xlDown)).Offset(0, -1).Resize(, 2).Copy

With ws2
.Range("Y6").PasteSpecial _
Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=False

.Range("C154:K185").Copy

Set rng = ws1.Columns("B")

Set rng2 = rng.Find(What:="*", _
After:=rng.Cells(rng.Cells.Count), _
LookIn:=xlValues, _
SearchDirection:=xlPrevious).Offset(0, -1)

Set rng2 = Nothing

Set rng2 = rng.Find(What:="*", _
After:=rng.Cells(rng.Cells.Count), _
LookIn:=xlValues, _
SearchDirection:=xlPrevious).Offset(0, -1)

.Range("C154:K185").Copy

rng2.PasteSpecial Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=False

ws1.Range("B7", Range("B7"). _
End(xlDown)).Offset(0, -1).Resize(, 2).Copy

.Range("AA6").PasteSpecial _
Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=False

.Range("C4").ClearContents
.Range("B6:F37").ClearContents
End With

Application.ScreenUpdating = False

End Sub
'<<=========================


---
Regards,
Norman


"TTomSawyer" wrote
in message ...

Alright,

So these are the functions that i am copying and pasting from:

=IF(D13="","","Cash")

So if the box d13 has somethign in it, it says cash, otherwise it does
nothing, sorta.

the macro for pasting from one sheet to the other is below:

ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("MASTER Pettycash and CC").Select
Range("B7").Select
Selection.End(xlDown).Select
Selection.End(xlToLeft).Select
Selection.Copy
Sheets("PETTY CASH INPUT").Select
Range("Y6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=False
Range("C154:K185").Select
Selection.Copy
Sheets("MASTER Pettycash and CC").Select
Range("B7").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=False
Range("B7").Select
Selection.End(xlDown).Select
Selection.End(xlToLeft).Select
Selection.Copy
Sheets("PETTY CASH INPUT").Select
Range("AA6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=False
ActiveWindow.ScrollColumn = 1
Range("B6:F37").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("C4").Select
Selection.ClearContents
Range("AA6").Select
End Sub


--
TTomSawyer
------------------------------------------------------------------------
TTomSawyer's Profile:
http://www.excelforum.com/member.php...o&userid=20511
View this thread: http://www.excelforum.com/showthread...hreadid=395945



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pasting Blanks using a macro


Hrm,
this didnt work, it resulted in a few errors.
specifically regarding the line with


ws1.Range("B7", Range("B7"). _
End(xlDown)).Offset(0, -1).Resize(, 2).Copy


--
TTomSawyer
------------------------------------------------------------------------
TTomSawyer's Profile: http://www.excelforum.com/member.php...o&userid=20511
View this thread: http://www.excelforum.com/showthread...hreadid=395945



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Pasting Blanks using a macro

Hi TTomSawyer.

Correcting qualification errors, again on a copy, try:

Sub Tester02()
Dim rng As Range
Dim rng2 As Range
Dim ws1 As Worksheet
Dim ws2 As Worksheet

Application.ScreenUpdating = False

Set ws1 = Sheets("MASTER Pettycash and CC")
Set ws2 = Sheets("PETTY CASH INPUT")

With ws1
.Range(.Range("B7"), .Range("B7"). _
End(xlDown)).Offset(0, -1).Resize(, 2).Copy
End With
With ws2
.Range("Y6").PasteSpecial _
Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=False

.Range("C154:K185").Copy

Set rng = ws1.Columns("B")

Set rng2 = rng.Find(What:="*", _
After:=rng.Cells(rng.Cells.Count), _
LookIn:=xlValues, _
SearchDirection:=xlPrevious).Offset(0, -1)

Set rng2 = Nothing

Set rng2 = rng.Find(What:="*", _
After:=rng.Cells(rng.Cells.Count), _
LookIn:=xlValues, _
SearchDirection:=xlPrevious).Offset(0, -1)

.Range("C154:K185").Copy

rng2.PasteSpecial Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=False
End With

With ws1
.Range(.Range("B7"), .Range("B7"). _
End(xlDown)).Offset(0, -1).Resize(, 2).Copy
End With

With ws2
.Range("AA6").PasteSpecial _
Paste:=xlValues, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=False

.Range("C4").ClearContents
.Range("B6:F37").ClearContents
End With

Application.ScreenUpdating = False

End Sub
'<<=========================


---
Regards,
Norman



"TTomSawyer" wrote
in message ...

Hrm,
this didnt work, it resulted in a few errors.
specifically regarding the line with


ws1.Range("B7", Range("B7"). _
End(xlDown)).Offset(0, -1).Resize(, 2).Copy


--
TTomSawyer
------------------------------------------------------------------------
TTomSawyer's Profile:
http://www.excelforum.com/member.php...o&userid=20511
View this thread: http://www.excelforum.com/showthread...hreadid=395945



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
macro to fill in rows with blanks hnyb1 Excel Discussion (Misc queries) 5 September 9th 09 03:26 PM
Excel 2002: How to avoid pasting blanks ? Mr. Low Excel Discussion (Misc queries) 3 September 15th 07 02:17 AM
Fill Blanks Macro LLoraine Excel Discussion (Misc queries) 2 August 29th 07 03:12 PM
Paste Special Skip Blanks not skipping blanks, but overwriting... gsrosin Excel Discussion (Misc queries) 0 February 22nd 05 03:33 AM
Macro - trailing blanks Dennis Griffith Excel Programming 0 September 4th 03 02:37 PM


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