Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default Insert Blank row and paste information

I have a spread sheet I am using to combine two reports from a DB. One is an
Incident tracking and the other is Action Item tracking. I want to combine
all Incidents with the action item that is associated to it. I have an
action item id on both data sheets. I am new to excel programming, but have
found some helpful information here. This is what I have so far:

Private Sub CommandButton1_Click()
On Error GoTo Abort
Dim wb1 As Workbook


Dim rng1 As Range, rng2 As Range
Dim c As Range, cc As Range, ccc As Range, cccc As Range

Set wb1 = ThisWorkbook

Set rng1 = wb1.Sheets("Sheet1").Range("A2:A1000")
Set rng2 = wb1.Sheets("Data2").Range("K2:K1000")

For Each c In rng1
For Each cc In rng2
If c.Value = cc.Value And Len(c) 1 Then
Set ccc = c
Set cccc = wb1.Sheets("Data2").Range("A" & cc.Row & ":" & "J" &
cc.Row)
cccc.Copy
ccc.Offset(1, 6).PasteSpecial xlPasteValues

Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
Next
Next
Exit Sub
Abort:
msgbox "Error: " & Err.Description & ", " & Err.Source
End Sub

This works, but I need for it to insert a blank row. Now it is inserting
the information on the next line with other incident information. It also
seems to only paste the first AI associated with an incident. Any Ideas how
I can make this work?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default Insert Blank row and paste information

Record a macro to insert a row, you can get the code from that.

--
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Kevin" wrote in message ...
I have a spread sheet I am using to combine two reports from a DB. One is an
Incident tracking and the other is Action Item tracking. I want to combine
all Incidents with the action item that is associated to it. I have an
action item id on both data sheets. I am new to excel programming, but have
found some helpful information here. This is what I have so far:

Private Sub CommandButton1_Click()
On Error GoTo Abort
Dim wb1 As Workbook


Dim rng1 As Range, rng2 As Range
Dim c As Range, cc As Range, ccc As Range, cccc As Range

Set wb1 = ThisWorkbook

Set rng1 = wb1.Sheets("Sheet1").Range("A2:A1000")
Set rng2 = wb1.Sheets("Data2").Range("K2:K1000")

For Each c In rng1
For Each cc In rng2
If c.Value = cc.Value And Len(c) 1 Then
Set ccc = c
Set cccc = wb1.Sheets("Data2").Range("A" & cc.Row & ":" & "J" &
cc.Row)
cccc.Copy
ccc.Offset(1, 6).PasteSpecial xlPasteValues

Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
Next
Next
Exit Sub
Abort:
msgbox "Error: " & Err.Description & ", " & Err.Source
End Sub

This works, but I need for it to insert a blank row. Now it is inserting
the information on the next line with other incident information. It also
seems to only paste the first AI associated with an incident. Any Ideas how
I can make this work?



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
How can I insert a true blank inst. of a non-blank zero string MF Excel Worksheet Functions 2 October 30th 09 01:58 PM
How to eliminate blank rows between information juliomex Excel Discussion (Misc queries) 2 November 28th 08 03:43 AM
What does InsertNameLabel & InsertNamePaste do? Studebaker Excel Discussion (Misc queries) 2 June 12th 08 04:13 AM
Insert Information in a different worksheet Matt Excel Discussion (Misc queries) 1 November 27th 07 01:03 PM
How can I insert a new information between two rows? DianeH Excel Worksheet Functions 1 May 17th 06 08:58 PM


All times are GMT +1. The time now is 01:08 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"