Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Check Values/Insert Rows

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Check Values/Insert Rows

On Mar 27, 1:41 pm, "Dan R." 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Check Values/Insert Rows

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
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
Insert 5 rows between existing values in a single column 1 camsd Excel Worksheet Functions 7 October 16th 08 08:56 PM
Insert Rows Based on values in another worksheet Jason Excel Discussion (Misc queries) 3 June 24th 07 01:13 PM
check for insert row action... mark kubicki Excel Programming 0 May 26th 06 01:07 AM
Luk strings, write values / balance, insert rows : wanted VB help Eddy Stan Excel Programming 5 March 29th 06 05:41 AM
Insert Textbox values to seperate rows/columns thompssm Excel Programming 3 December 1st 05 09:53 PM


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