Macro Won't Leave Blank Cells

pezram

New Member
Joined
Dec 10, 2014
Messages
4
In this formula I would like it to skip blank cells In the "a" column of the sheet I am copying from any suggestions would be appreciated. If there is no data in the A column I want to skip pasting it to the trades sheet.


Code:
Sub copypaste()
  Dim lrb As Long
  With Sheets("trades")
    lrb = .Range("a" & Rows.Count).End(3).Row
    Sheets("Journal").Range("a8:n22,T8:T22").Copy
    .Range("a" & lrb + 1).PasteSpecial (xlPasteValues), Operation:=xlNone, SkipBlanks _
        :=True, Transpose:=False
  End With
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi Try this ...
Code:
Sub copypaste()
  Dim lrb As Long
  With Sheets("trades")
    lrb = .Range("a" & Rows.Count).End(3).Row
    If Evaluate("countA(A8:A22)") > 0 Then
    Sheets("Journal").Range("a8:n22,T8:T22").Copy
    .Range("a" & lrb + 1).PasteSpecial (xlPasteValues), Operation:=xlNone, SkipBlanks _
        :=True, Transpose:=False
    End If
  End With
End Sub
 
Upvote 0
Unfortunately doing the same thing sometimes my sheet will have data in some of the columns right of the "A" column I only want to copy it if it has data in the A column. Thanks for the help.
 
Upvote 0
Hi I guess... You are looking for this ...
Code:
Sub copypaste()
  Dim lrb As Long
  With Sheets("trades")
    lrb = .Range("a" & Rows.Count).End(3).Row
    
    For i = 1 To 22
        If Sheets("Journal").Range("a" & i).Value <> "" Then
            AN = Intersect(Sheets("Journal").Range("A:N"), Sheets("Journal").Range(i & ":" & i)).Address
            TT = Intersect(Sheets("Journal").Range("T:T"), Sheets("Journal").Range(i & ":" & i)).Address
            Rng = AN & "," & TT
            Sheets("Journal").Range(Rng).Copy
            .Range("a" & lrb + 1).PasteSpecial xlPasteValues
            lrb = lrb + 1
        End If
    Next
  End With
End Sub

Let me know if its fine otherwise details your requirement...
 
Upvote 0
Thanks puru.sve that solved the blank cells but just want it to copy from row A8 to N22 and T8 to T22, thanks for your help new to this macro stuff.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top