Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

!!! Can someone please help me with my VBA macro! It is running but everything is highlighted green, and I still have some negatives. !!!

!!! Can someone please help me with my VBA macro! It is running but everything is highlighted green, and I still have some negatives. !!!

***********************BEWLOW IS THE INTRUCTIONS FOR WHAT THE CODE SHOULD DO***********************************

Write a VBA macro referencing the data on the VBA Problem Starting Data tab. Your macro should do the following. (Note: You should be able to complete all these tasks by running your macro one time. You will lose points if you must run your macro multiple times to complete the tasks.) a. Flip the sign for any negative values in the Amount Requested column. i. Ex/ -24,000 24,000 b. Highlight columns A K for each row according to these rules. (If everyone in your group is color-blind, please let me know.) i. The rows for Amounts Requested less than 3,000 should be green. ii. The rows for Amounts Requested less than 19,000 but more than 2,999 should be blue. iii. The rows for Amounts Requested more than 18,999 should be orange. c. Delete any record with an absolute value of Amount Requested more than 25,000. (i.e. more than 25,000 or less than -25,000) d. The macro should be triggered from a button located on the VBA Setup Instructions tab. e. Once complete, the macro should select cell A1 on the VBA Problem Starting Data tab.

*********************************************BELOW IS MY CODE THAT IS NOT WORKING************************************************

Option Explicit

Sub DataCleanup() ' ' Multi_purposeGP Macro ' This Macro will flip the signs of negative values, highlight columes A-K accordingly, and delete any record with an absolute value of Amount Requested more than 25,000. '

' Dim LastRow As Long Dim i As Long Dim amtRequested As Double LastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = 2 To LastRow amtRequested = Cells(i, "K").Value If amtRequested < 0 Then Cells(i, "K").Value = -amtRequested End If If amtRequested < 3000 Then Range("A" & i & ":K" & i).Interior.ColorIndex = 4 'green ElseIf amtRequested < 19000 Then Range("A" & i & ":K" & i).Interior.ColorIndex = 5 'blue Else Range("A" & i & ":K" & i).Interior.ColorIndex = 46 'orange End If If Abs(amtRequested) > 25000 Then Rows(i).Delete i = i - 1 LastRow = LastRow - 1 End If Next i Sheets("VBA Problem - Starting Data").Activate Range("A1").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

Forensic Accounting And Financial Statement Fraud Forensic Accounting Performance

Authors: Zabihollah Rezaee

1st Edition

1949991075, 978-1949991079

More Books

Students also viewed these Accounting questions

Question

Evaluate three pros and three cons of e-prescribing

Answered: 1 week ago