Solved

Another Related Question

Posted on 2016-09-06
6
27 Views
Last Modified: 2016-09-27
I had this question after viewing EXCEL Match data rows in excel.  (not same amount of values).

I have data in column E that needs to stay tied to Column D and/or Column C.

Any suggestion to include that in the MACRO you wrote?
0
Comment
Question by:Julie Lyman
  • 4
  • 2
6 Comments
 
LVL 25

Expert Comment

by:ProfessorJimJam
Comment Utility
yes, use the code below and it will not touch your column E.  

Option Explicit

Sub Test()
Dim i As Long, lastrow As Long
Application.ScreenUpdating = False
 lastrow = Range("C" & Rows.Count).End(xlUp).Row

    Columns("A:E").Sort Key1:=Range("A2"), order1:=xlAscending, _
        Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
    Columns("C:E").Sort Key1:=Range("C2"), order1:=xlAscending, _
        Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
    i = 2 '  if your data has header. if not change to 1
    Do
        If Cells(i, "A") > Cells(i, "C") And Cells(i, "C") > "" Then
            Cells(i, "A").Resize(1, 2).Insert xlShiftDown
        ElseIf Cells(i, "A") < Cells(i, "C") And Cells(i, "A") > "" Then
            Cells(i, "C").Resize(1, 2).Insert xlShiftDown
        End If
        i = i + 1
    Loop Until Cells(i, "A") = "" And Cells(i, "C") = ""
Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Comment

by:Julie Lyman
Comment Utility
I tried this and I actually want Column D and E to stay "connected"  

Before the Macro is Run on the same row Sample Data is:  
Sample of Column D Data might be:  449303 OIL CLOTH MFG                        
Sample of Column E Data Might be:  <option value="449303">OIL CLOTH MFG                      </option>

I want the same matching data in Column D and E, however the result will be on a different Row based on what you wrote in the original MACRO.
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
Comment Utility
Can you depict this with an example as you did in your previous question . Two tables the current and the one aftermath
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:Julie Lyman
Comment Utility
I have an attached sample of Data
Sheet:  PreMacro
Sheet:  Post Macro

In the Post Macro you will see that I have inserted 2 columns A and B

The data we originally discussed as sample data was columns A-D,  and has been moved to Columns C-F



Both Column A and B are using Formulas, Post Macro is the desired result.

The only thing I need currently is for Column G to move with Column F, when your macro is run.

Note:  that there is a few manual changes I have to make in order to match the Description Columns D and F.  You can see that code 1803 as an example.  I am manually matching the data in column D with Column F.
DataSample.xlsm
0
 
LVL 25

Accepted Solution

by:
ProfessorJimJam earned 500 total points (awarded by participants)
Comment Utility
Hi, i just looked at your sample data uploaded, it contradicts with the description you are giving.

the sheet pre macro has 5 columns with data and your post macro sheet has 7. how these can correlate, it  cannot.  

the question you asked was to align rows.

i have attached a solution to the example you previously provided and there i added addition column and when you run the macro, the addtional column of E will not be affected and will move along the column C and D
EE.xlsm
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
Comment Utility
.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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 view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar 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

7 Experts available now in Live!

Get 1:1 Help Now