Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How do I avoid copying data into blank cells

I have data in cells in rows C,D,AF&BL Im copy and pasting to another
worksheet. What im trying to do is if there is not data in cells in row
AF&BL I dont want it to copy the column onto the new worksheet. Cells
in row C&D will always have data in it.

I.E 1) column no 3 has data in row C&D but NO data in AF & BL . I do
not want any data in that column(inc columns c&d) copied over.
2) column no4 has data in row C&D and also data in either AF&BL this
one I DO want copied over.

When I mean copied over I mean the data in cells C,D,AF&BL.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default How do I avoid copying data into blank cells


wrote:
I have data in cells in rows C,D,AF&BL Im copy and pasting to another
worksheet. What im trying to do is if there is not data in cells in row
AF&BL I dont want it to copy the column onto the new worksheet. Cells
in row C&D will always have data in it.

I.E 1) column no 3 has data in row C&D but NO data in AF & BL . I do
not want any data in that column(inc columns c&d) copied over.
2) column no4 has data in row C&D and also data in either AF&BL this
one I DO want copied over.

When I mean copied over I mean the data in cells C,D,AF&BL.


If I have what you are looking for straight (I was left a little
confused as to what you are calling rows and columns in the second
paragraph), something like the following is what you are looking for:

==================================

' Substitue the column letters in [ ] for the numeric equivalent (i.e.
C = 3)

Dim i as Integer
Dim c as Integer
Dim wsData as Worksheet
Dim wsPaste as Worksheet

Set wsData = Worksheets("[name of sheet copying from]")
Set wsPaste = Worksheets("[name of sheet pasting to]")

c = [the starting row number on the sheet you are pasting to, just use
"i" if you don't care about empty rows]

wsData.Activate

For i = 1 to ActiveSheet.UsedRange.Rows.Count ' Change 1 to 2 if you
have a header row

If (Cells(i,[AF].Value < "") Or (Cells(i,[BL].Value < "") Then
Rows(i).Select
Selection.Copy
wsPaste.Activate 'I am doing the paste part from memory, may
be off...
Rows(c).Select
ActiveSheet.Paste
c = c + 1
wsData.Activate
End If
Next i

Set wsData = Nothing
Set wsPaste = Nothing

==============================

You may want to set the screen updating to false before going into the
for loop and back to true after to loop unless you want Excel to blink
around as it steps through the loop, or you may want to use the status
bar to count the row you are working on (displaying the value of i) to
keep track of where it is...

David

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How do I avoid copying data into blank cells


Dove wrote:
wrote:
I have data in cells in rows C,D,AF&BL Im copy and pasting to another
worksheet. What im trying to do is if there is not data in cells in row
AF&BL I dont want it to copy the column onto the new worksheet. Cells
in row C&D will always have data in it.

I.E 1) column no 3 has data in row C&D but NO data in AF & BL . I do
not want any data in that column(inc columns c&d) copied over.
2) column no4 has data in row C&D and also data in either AF&BL this
one I DO want copied over.

When I mean copied over I mean the data in cells C,D,AF&BL.


If I have what you are looking for straight (I was left a little
confused as to what you are calling rows and columns in the second
paragraph), something like the following is what you are looking for:

==================================

' Substitue the column letters in [ ] for the numeric equivalent (i.e.
C = 3)

Dim i as Integer
Dim c as Integer
Dim wsData as Worksheet
Dim wsPaste as Worksheet

Set wsData = Worksheets("[name of sheet copying from]")
Set wsPaste = Worksheets("[name of sheet pasting to]")

c = [the starting row number on the sheet you are pasting to, just use
"i" if you don't care about empty rows]

wsData.Activate

For i = 1 to ActiveSheet.UsedRange.Rows.Count ' Change 1 to 2 if you
have a header row

If (Cells(i,[AF].Value < "") Or (Cells(i,[BL].Value < "") Then
Rows(i).Select
Selection.Copy
wsPaste.Activate 'I am doing the paste part from memory, may
be off...
Rows(c).Select
ActiveSheet.Paste
c = c + 1
wsData.Activate
End If
Next i

Set wsData = Nothing
Set wsPaste = Nothing

==============================

You may want to set the screen updating to false before going into the
for loop and back to true after to loop unless you want Excel to blink
around as it steps through the loop, or you may want to use the status
bar to count the row you are working on (displaying the value of i) to
keep track of where it is...

David




Many Thanks

GLENN

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
how can i fill data in blank cells after copying a pivot report? Antz Excel Discussion (Misc queries) 1 August 7th 08 02:11 PM
How do I avoid copying data from hidden rows/columns? Fred Excel Discussion (Misc queries) 2 February 22nd 08 08:43 PM
how can avoid considering of blank cells in IF function Lika Excel Worksheet Functions 1 June 12th 06 10:27 AM
Excel truncated my cells when copying, how to avoid?? bxc2739 Excel Discussion (Misc queries) 0 March 17th 06 04:40 PM
Automatic copying data excluding blank cells Wesley Excel Worksheet Functions 6 November 30th 04 01:17 AM


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