Wrox Programmer Forums
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 5th, 2005, 12:16 AM
Authorized User
Join Date: Nov 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default two questions

1) is there any . or is function that deals with the background color?
i need to use it like:
if cells(i,1).backcolor=6 then
2)i know absolutely nothing about strings and i want to make my button idiot proof so i want it to be
if textbox.value>1000 because the minimum is 4 digits but sometimes there will be two letters on the end. so i need to know how to subtract 2 characters off of a string if the string is =6
Old December 5th, 2005, 01:20 AM
Registered User
Join Date: Oct 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to ix_ly Send a message via MSN to ix_ly


For question 1, the solution might be
range("B3").Interior.ColorIndex = 10

well, i not really understand what you're asking at question 2.


Old December 5th, 2005, 06:33 AM
Authorized User
Join Date: Oct 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shattered Send a message via Yahoo to shattered

' Method 1
Function RightLen(sText As String) As Integer
    If Len(sText) = 6 Then
        RightLen = Left(sText, 4)
        RightLen = sText
    End If
End Function

' Method 2
Function ValidNum(sText As String) As Integer
    If IsNumeric(sText) Then
        ValidNum = sText
        ValidNum = Left(sText, 4)
    End If
End Function

In either instance just use the function to get the actual value and then test against it

Sub CheckValue()
    If RightLen(TextBox.Value) > 1000 Then
        ' Do Something....
    End If
End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Interview Questions, C# Interview Questions, dotnetuncle .NET Framework 2.0 4 June 22nd, 2019 07:03 AM
C++ questions jam93 C++ Programming 1 August 19th, 2007 10:39 PM
C# questions zhenliu C# 1 April 15th, 2004 09:18 AM
questions anshul Javascript How-To 1 April 12th, 2004 07:29 AM
many questions Frank1111 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 December 22nd, 2003 09:59 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.