Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default skip blank rows

how do i skip blank rows? sheet 1 has d10=alex, d17=ben, d24=carlo, i
transferred them to sheet 2,
B4 alex 1
<blank
<blank
B11 ben 2
<blank
<blank
B18 carlo 3

what do i need to add in my code?
Sub Macro1()
Application.ScreenUpdating = False

rowref = Sheet6.Cells(2, 2)
Sheets("Dept Summary").Select
a = 3
For X = 10 To rowref Step 1
a = a + 1
Name = Sheet2.Cells(X, 4)
Sheets("PHTemp").Select
Cells(a, 2) = Name
Next X

Sheets("Dept Summary").Select
destcol = 3
For rowtocopy = 10 To rowref Step 1
destcol = destcol + 1
Range(Cells(rowtocopy, 29), Cells(rowtocopy, 35)).Select
Selection.Copy
Sheets("PHTemp").Select
Cells(destcol, 5).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Sheets("Dept Summary").Select
Next rowtocopy
Sheets("PHTemp").Select

Application.ScreenUpdating = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default skip blank rows

thank you mauro! it worked!

"Mauro Gamberini" wrote:

Public Sub m()

On Error GoTo ErrorRow

Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim lLastRow As Long
Dim rng As Range

With Application
.ScreenUpdating = False
.Calculation = xlManual
.StatusBar = "Runs: Sub m()"
End With

Set sh1 = Worksheets("Sheet1")
Set sh2 = Worksheets("Sheet2")

With sh1
lLastRow = _
.Range("D" & Rows.Count).End(xlUp).Row
Set rng = _
.Range("D2:D" & _
lLastRow).SpecialCells( _
xlCellTypeConstants)
rng.Copy sh2.Range("B2")
End With

ExitRow:
Set rng = Nothing
Set sh2 = Nothing
Set sh1 = Nothing
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.StatusBar = ""
End With
Exit Sub

ErrorRow:
MsgBox Err.Number & vbNewLine & Err.Description
Resume ExitRow

End Sub


--
---------------------------
Mauro Gamberini
http://www.riolab.org/
"louie" ha scritto nel messaggio
...
how do i skip blank rows? sheet 1 has d10=alex, d17=ben, d24=carlo, i
transferred them to sheet 2,




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
Need to number but skip blank rows FJ Excel Discussion (Misc queries) 7 August 19th 09 10:50 AM
copy from one sheet to another and skip the blank rows Dawn Excel Discussion (Misc queries) 3 March 11th 09 07:46 PM
Need simple code to skip blank rows [email protected] Excel Programming 8 January 30th 07 04:27 PM
skip blank rows when pasting formulas Newsgal Excel Worksheet Functions 1 June 22nd 05 10:13 PM
how to skip the blank cells nayeemoddin Excel Discussion (Misc queries) 1 December 6th 04 07:07 AM


All times are GMT +1. The time now is 10:15 PM.

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"