Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the following VBA code for Excel I want to highlight all cells with low in a column and paste them somewhere new after sorting

In the following VBA code for Excel I want to highlight all cells with "low" in a column and paste them somewhere new after sorting them- and then highlight all left over cells which say "high" and group them together. Right now I recorded the macro so it's copy-paste. But, the range may increase and decrease so the copy-paste won't always work if I make any changes to the data! How can i make this work for a moving range?

-When I move the data I want to transpose another column and give the relationships a 2 or a 3 or a 1 rather than filling it in as seen in code below! HELP!

Sub Highlight_Move_High_Risk()

'

' Pair_High_Risk Macro

'

'

Range("A1:E12").Select

Selection.Copy

Range("K1").Select

ActiveSheet.Paste

End Sub

Sub Pair_Low_Risk()

'

' Pair_Low_Risk Macro, This Grabs all the low Risk Levels and groups

'them together

Range("A1:E1,A13:E31").Select

Range("A13").Activate

Selection.Copy

Range("K17").Select

ActiveSheet.Paste

Range("K17:K37").Select

Selection.Copy

Range("Q17:Q36").Select

ActiveSheet.Paste

ActiveSheet.Paste

Application.CutCopyMode = False

End Sub

Sub Value_Relationship()

'

' Value_Relationship Macro

'

'

Range("K1:K12").Select

Selection.Copy

Range("Q1").Select

ActiveSheet.Paste

Range("N2:N12").Select

Application.CutCopyMode = False

Selection.Copy

Range("R1").Select

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _

, Transpose:=True

Range("R2").Select

Application.CutCopyMode = False

ActiveCell.FormulaR1C1 = "3"

Range("S3").Select

ActiveCell.FormulaR1C1 = "3"

Range("T4").Select

ActiveCell.FormulaR1C1 = "3"

Range("U5").Select

ActiveCell.FormulaR1C1 = "3"

Range("V6").Select

ActiveCell.FormulaR1C1 = "3"

Range("W7").Select

ActiveCell.FormulaR1C1 = "3"

Range("X8").Select

ActiveCell.FormulaR1C1 = "3"

Range("Y9").Select

ActiveCell.FormulaR1C1 = "3"

Range("Z10").Select

ActiveCell.FormulaR1C1 = "3"

Range("AA11").Select

ActiveCell.FormulaR1C1 = "3"

Range("AB12").Select

ActiveCell.FormulaR1C1 = "3"

Range("O2:O12").Select

Selection.Copy

Range("AC1").Select

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _

, Transpose:=True

Range("AC2").Select

Application.CutCopyMode = False

ActiveCell.FormulaR1C1 = "2"

Range("AD3").Select

ActiveCell.FormulaR1C1 = "2"

Range("AE4").Select

ActiveCell.FormulaR1C1 = "2"

Range("AF5").Select

ActiveCell.FormulaR1C1 = "2"

Range("AG6").Select

ActiveCell.FormulaR1C1 = "2"

Range("AH7").Select

ActiveCell.FormulaR1C1 = "2"

Range("AI8").Select

ActiveCell.FormulaR1C1 = "2"

Range("AJ9").Select

ActiveCell.FormulaR1C1 = "2"

Range("AK10").Select

ActiveCell.FormulaR1C1 = "2"

Range("AL11").Select

ActiveCell.FormulaR1C1 = "2"

Range("AM12").Select

ActiveCell.FormulaR1C1 = "2"

Range("AN12").Select

'End Sub

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

Be able to cite the advantages of arbitration

Answered: 1 week ago

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago