View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Indexing or Ignore Blank rows

Good possibility that when you insert your row, you clear the clipboard - so
when you try to paste you get an error.

Assume the sheet with the data has the code name sheet1

Dim Col as String
Dim JobNumb as String



With Sheet1.Range("E5")
if .Value < "" then
Col = "E" 'variable to set column on next sheet
JobNumb = Sheet5.Range("E5").Value 'job number format ~"18000LT"
Insert_1_row 'sub to go to worksheet and insert blank row
.copy
selection.PasteSpecial xlpasteValues
' or selection.Value = Value
End if
End with

or if Sheet5 is the source sheet

With Sheet5.Range("E5")
if .Value < "" then
Col = "E" 'variable to set column on next sheet
JobNumb = .Range("E5").Value 'job number format ~"18000LT"
Insert_1_row 'sub to go to worksheet and insert blank row
.copy
selection.PasteSpecial xlpasteValues
' or selection.Value = Value (skip the copy
' or selection = JobNumb (skip the copy
end if
End with

It isn't totally clear to me what Sheet5 is - the source sheet or the
destination sheet and of course, I don't know what happens in Insert_1_row,
but assume that result of that sub is that the destination cell is selected.

The main point is that you will enjoy the most success if you copy and paste
in one command or for paste special, in successive commands.

When pasting values for single cells you can do

destinationCell = sourceCell and skip the copy and paste

Adjust to fit.

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
On Feb 17, 11:54 am, Joel wrote:
If you enter in the first few rows the sequence of numbers. It could be
1 2
3 or even 5 10 15. Then select the sequece with the mouse. You will see
a
black square on the lower right corner of the selected cells. Use the
mouse
and pull it down the black square to rest of the worksheet and the
numbers
will automatically be placed in the cells.


One big problem, my worksheet entries and blank rows are not in a
predictable order. I might have 3 entries under one job number and 75
under another, then a blank row in-between different job numbers. I
couldn't find a way to fill because the blank rows do not get assigned
series numbers.

I hate to do this but since I've got Tom's attention I'll ask; I'm am
also have trouble with the code below. It is copying a value from cell
E5 "18002LT" and pasting it to another worksheet, JobNum is dimmed
public as variant and all cells for copy and paste are General format.
It is returning error '1004' PasteSpecial method of Range class
failed, I have tried dimming JobNum as string, setting all cells in
question as Text, and tried all PasteSpecial methods. What am I not
getting set correctly?

If Range("E5").Value < "" Then
Range("E5").Copy 'Copying text from pull down list.
Col = ("E") 'variable to set column on next sheet
JobNumb = Sheet5.Range("E5").Value 'job number format
~"18000LT"
Insert_1_row 'sub to go to worksheet and insert blank row
Selection.PasteSpecial (xlPasteValues)
End If

Thanks,

Chad