Results 1 to 7 of 7

Thread: How to fill color in a particular Excel cell ??

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    63

    Question How to fill color in a particular Excel cell ??

    Hi!
    I just wanted to know how to color a particular cell in an excel worksheet. I guess it wont be that difficult but dun know the command to do this.. Please Help

    cheers
    Abhilash


    PS: I also wanted to know how to use checkboxes in a windows form. I would be thankful if anyone can help me out..

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: How to fill color in a particular Excel cell ??

    Hi Abhi

    Lets say you want to color the cell E6 Red then follow the below code

    vb Code:
    1. Range("E6").Select
    2.     With Selection.Interior
    3.         .ColorIndex = 3
    4.         .Pattern = xlSolid
    5.     End With

    Remember, whenever in doubt, simply record a macro

    Also check out the FAQ's on How to record a Macro. I believe Rob has it covered in the FAQ's

    Regd Checkboxes, what exactly do you want to do?

    ps: You can add checkboxes in the design mode and then double click on the control to get to the code area to type in the code.

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    63

    Re: How to fill color in a particular Excel cell ??

    hi..
    thx for the help.. wanted to ask.. can i run a macro through a vb code..
    oh.. so the method for checkboxes and buttons are the same is it..??

    cheers
    Abhilash

  4. #4
    Member
    Join Date
    Nov 2003
    Location
    Cambs, UK
    Posts
    55

    Re: How to fill color in a particular Excel cell ??

    Essentially your macro is VB code, so there's no issue there - just call it as a separate function from your VB code.


    Did you want to add checkboxes etc in Excel or Access?


    ~ James

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    63

    Re: How to fill color in a particular Excel cell ??

    oh ok.. thx james..

    i wan to add checkboxes in a normal windows form.. but i am writing a code which performs functions on excel depending on which checkboxes are checked..

    precisely, the only difference will be in the column name which is worked on depending on which box is checked..

    cheers
    Abhilash

  6. #6
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: How to fill color in a particular Excel cell ??

    Incidentally, did you know that there is a property called LinkedCell for objects in the main Excel sheet, and ControlSource for those on a UserForm, which link the value of a checkbox (etc) to an Excel cell, so that changes in the box can be referred directly into the sheet and vice versa. You could therefore use conditional formatting - if the value of a particular cell is TRUE then set a certain colour and if FALSE then set another. All this accomplished without any need for code.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    63

    Re: How to fill color in a particular Excel cell ??

    Hey thx zaza..

    I'll try to find out more on this..

    cheers
    Abhilash

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width