Solved

Copy Row of Data

Posted on 2013-06-03
3
186 Views
Last Modified: 2013-06-03
I'm trying to figure out a way to copy my row of information to another worksheet in my workbook if there is text in Column A, and a date in Column B. Data will be in Column C to Q. I would like to have it LOOP so when a user clicks a button and the VBA code looks down Column A and Column B to see if there is any data it would then move the row of data in column A to column Q to the last available row of a worksheet called 'Detail'.
TransferData.xls
0
Comment
Question by:Southern_Gentleman
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Pls try

Sub DoIt()

Dim shData As Worksheet
Dim shDetail As Worksheet

Set shData = Worksheets("Data")
Set shDetail = Worksheets("Detail")

On Error Resume Next
For IdxRow = shData.Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
    If WorksheetFunction.IsText(Cells(IdxRow, "A").Value) And IsDate(Cells(IdxRow, "B").Value) Then
        Application.CutCopyMode = False
        shData.Range(Range("A" & IdxRow), Range("Q" & IdxRow)).Cut _
            Destination:=shDetail.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
        shData.Cells(IdxRow, 1).EntireRow.Delete Shift:=xlUp
    End If
Next
End Sub

Open in new window

EDIT Corrected Bug
Regards
0
 

Author Comment

by:Southern_Gentleman
Comment Utility
Right on. Works great! Gonzo
0
 

Author Closing Comment

by:Southern_Gentleman
Comment Utility
Awesom
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now