PC Review


Reply
Thread Tools Rate Thread

Check Values/Insert Rows

 
 
Dan R.
Guest
Posts: n/a
 
      27th Mar 2007
Say I have a spreadsheet that has these values on Sheet1 Column A:
A
B
C
D
E

Then I copy & paste this onto Sheet2 Column A:
A
C
E

I need a macro to automatically recognize the missing values and
insert rows accordingly... I know this isn't hard but I can't think of
how to do it.

Thanks,
-- Dan

 
Reply With Quote
 
 
 
 
matt
Guest
Posts: n/a
 
      27th Mar 2007
On Mar 27, 1:41 pm, "Dan R." <Dan.R.Oa...@gmail.com> wrote:
> Say I have a spreadsheet that has these values on Sheet1 Column A:
> A
> B
> C
> D
> E
>
> Then I copy & paste this onto Sheet2 Column A:
> A
> C
> E
>
> I need a macro to automatically recognize the missing values and
> insert rows accordingly... I know this isn't hard but I can't think of
> how to do it.
>
> Thanks,
> -- Dan


If the letters are always a-z then you could use the Chr function
(65-90 is A - Z; 97-122 is a - z) in a For...Next loop. (e.g.
Chr(119) = w). You can load the 2 sets into arrays and then compare
the arrays.

Matt

 
Reply With Quote
 
Dan R.
Guest
Posts: n/a
 
      27th Mar 2007
Unfortunately the letters won't always be A-Z, I just used that as an
example. This is what I've come up with so far... it's pretty close.
Am I missing something?

Sub Test()
Dim i As Range
Dim iRng As Range
Dim x As Integer

Set ws = ActiveSheet
Set Q = Sheets(1)

Set iRng = ws.Range(Cells(1, 1), Cells(6, 1))

With ws
For Each i In iRng
For x = 1 To 5
If i.Value = Q.Cells(x, 1).Value Then
i.EntireRow.Cut .Cells(x, 1)
End If
Next
Next
End With

End Sub

Thanks,
-- Dan

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count rows b/w values and insert that # of rows elsewhere Robin Microsoft Excel Programming 1 21st Dec 2009 05:16 PM
Insert 5 rows between existing values in a single column 1 camsd Microsoft Excel Worksheet Functions 7 16th Oct 2008 08:56 PM
Insert Rows Based on values in another worksheet =?Utf-8?B?SmFzb24=?= Microsoft Excel Misc 3 24th Jun 2007 01:13 PM
Re: Insert Textbox values to seperate rows/columns Rowan Drummond Microsoft Excel Programming 1 1st Dec 2005 09:53 PM
Insert values into a table based on check box being on or off. =?Utf-8?B?Q0xVNzM=?= Microsoft Access 3 27th Jan 2005 10:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:47 AM.