Excel/Highlight a Range

Advertisement


Question
QUESTION: Dear Marcrodos,

I need your assistance in a very easy question.

How can we Highlight the range or cell when sum of that range reached upto total '100'?

I know its a very simple question, but I do not know from where I need to start with.

Please provide your assistance on given question. I will be very thankful to you.

Thanks
Shoaib

ANSWER: Hello you can:

Sub marca ()
If range("a1")=100 then
Range ("a1").select
End sub


Visit http://programarexcel.com




---------- FOLLOW-UP ----------

QUESTION: Dear Marcrodos,

Thanks for your reply. Unfortunately, this is not answer of my question.

My question is: How can I color the range when sum of the range is equal to "100".

You can see below example the sum of A1 to A6 is 100. Now I color the range from A1 to A6 only.

For Eg:
  A
1 10
2 10
3 10
4 10
5 30
6 30
7 50
8 60
9 20
10 70

Hope this my time I am clear with my question.

Regards,
Shoaib

Answer
hello Use this macro incorporates a module copy and paste the code

Sub Sel()
Dim fila, conta, contat, filar1, filar2 As Integer
fila = 2
conta = 0
contat = 0
filar1 = 2
filar2 = 2
While Sheets("hoja1").Cells(fila, 2) <> Empty
conta = Sheets("hoja1").Cells(fila, 2)
r1 = Sheets("hoja1").Cells(filar1, 2).Row
r2 = Sheets("hoja1").Cells(fila, 2).Row
contat = contat + conta
If contat >= 100 Then
Sheets("hoja1").Cells(fila, 2).Interior.Color = 255
conta = 0
contat = 0
filar1 = fila + 1
End If
fila = fila + 1
Wend
End Sub



http://programarexcel.com
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


marcrodos

Expertise

Expert programming macros or visual basic VBA that can help automate your Excel spreadsheets using VBA programming or macros to excel, forms and other procedures related to Macros. I also have an excellent command of Excel in almost its entirety, formulas, graphs, dynamic tables. In http://programarexcel.blogspot.com o www.programarexcel.com examples can download free excel macros programmed in VBA, macros can be downloaded and adapted to the project that you're doing to automate excel www.programarexcel.com

Experience

For several years, use Microsoft Excel on a daily basis, more specifically in my work, which is why over several years I have compiled a wealth of knowledge about their operation, adding to the basic operation of coding excel VBA macros to automate repetitive tasks . I serve as an expert in excel also in www.todoexpertos.com site, which I enjoy a great reputation. In http://programarexcel.blogspot.com o www.programarexcel.com examples can download free excel macros programmed in VBA, macros can be downloaded and adapted to the project that you're doing to automate excel www.programarexcel.com

Organizations
http://www.programarexcel.blogspot.com http://www.programarexcel.com

Publications
In public http://www.programarexcel.com o www.programarexcel.com continuously macro examples that readers can download for free and adapt to the needs of each project in excel that has the web page visitor

Education/Credentials
My profession's is a Chartered Accountant with experience in Excel, especially in VBA or macro programming, but also in the formulas and everything related to excel, I graduated several years ago at the National University of Cordoba, now I practice my profession in which a basic tool is excel. www.programarexcel.com

Awards and Honors
http://www.programarexcel.blogspot.com http://www.programarexcel.com

Past/Present Clients
http://www.programarexcel.blogspot.com http://www.programarexcel.com

©2016 About.com. All rights reserved.