VBA - Coping range IF column has a value in it - 99% done

Nemo74

New Member
Joined
Mar 22, 2013
Messages
38
Code:
Private Sub CommandButton1_Click()
    Dim c As Range
  
        For Each c In Range("F16:F30") 
        If IsNumeric(c.Value) Then
            c.Rows("1:1").EntireRow.Select
            Selection.Copy
           Sheets("Sheet2").Range("A65000").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
        End If
    Next c
End Sub

In the range of F16:F30 there are two cells with the number 5 in it. I just want the code to grab each entire row and copy the rows to Sheet 2.

This code grabs the line AFTER the last 5 in column F.

Where is my error?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Would you like me to share the other forums I asked the same question to fix the problem I am having?

That's what Rule 24 in http://www.mrexcel.com/forum/excel-questions/127080-guidelines-posting-updated-22-nov-2006-a.html says you should do.

But if it's going to be such a strain to click the link here are the words to that rule :-
24.Cross-posting is the term we use when a person has posted the same question to multiple online forums. While there is nothing actually "wrong" with this, it is asked that you at least mention that the question has been posted elsewhere, including a link to the thread on the other forum. There are many people who post at several different forums; threads are cross-posted without stating it are easily identified and pointed out as such.
1.Read: Excelguru Help Site - A message to forum cross posters

The fact that you cross-posted on the other forum only 2 minutes after posting here hardly gave members here a chance to respond.
 
Upvote 0
That's what Rule 24 in http://www.mrexcel.com/forum/excel-questions/127080-guidelines-posting-updated-22-nov-2006-a.html says you should do.

But if it's going to be such a strain to click the link here are the words to that rule :-


The fact that you cross-posted on the other forum only 2 minutes after posting here hardly gave members here a chance to respond.

I was unaware of rule 24, and this has been the 1st time i have been caught violatiing it. I am sorry for the snapy response and thanks for letting me know I was messing up. I will follow that rule from here on out. I was looking at more people to look at my issuse the better. I always post the solution on both sites no matter which forum finds it, so other memeber can see it.

That being said, the problem was solved with the the following code:

Code:
Private Sub CommandButton1_Click()
       Dim c As Range
    
    For Each c In Range("R2:R6")
        If IsNumeric(c.Value) Then
            c.Select
            ActiveCell.Offset(, -16).Resize(, 5).Copy
            Sheets("Sheet2").Range("A65000").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
        End If
    Next c
 End SubEnd Sub
 
Upvote 0

Forum statistics

Threads
1,215,717
Messages
6,126,422
Members
449,314
Latest member
MrSabo83

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