Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 June 14th, 2007, 05:17 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Analyze if ActiveCell is part of specified Range

Hi,

I'm trying to figure out how to get my macro to analyze if my ActiveCell is part of a specified Range. For instance, my ActiveCell is A2 but the Range I am analyzing against is Range("G:G"). Here is the code I'm working with:

1 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
2 Dim PubTag As Integer
3 Dim strCell As String
4 Dim rngCell As Range
5 Dim rngClick As Range

6 If IsEmpty(Target) Then

7 Set rngClick = Range(Target.Address & Target.Address).Select

8 If Range(rngClick) <> Range("G:G") Then
9 Exit Sub
10 Else
11 Range("G2").Select
12 Range(Selection, Selection.End(xlDown)).Select
13 PubTag = Selection.Cells.Count
14 End If
15 Else
16 Exit Sub
17 End If
18 End Sub

Line 8 of my code is where I'm stumped at how to get it to analyze if my ActiveCell is in the Range of G:G. I know what I currently have is not right. I've tried looking online but have not been able to find solutions that work with what I'm trying to accomplish.

I have to apologize. I am fairly new to VBA but any assistance or advice you have is much appreciated.

Kara
 
Old June 14th, 2007, 09:12 PM
Authorized User
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try If ActiveCell.Column <> Range("G:G").Column Then
    'code
Else
    'code
End If





Similar Threads
Thread Thread Starter Forum Replies Last Post
Analyze of a Blob yanis97 Java Databases 0 September 16th, 2006 12:04 PM
Analyze of a BLOB yanis97 J2EE 0 September 8th, 2006 05:37 AM
Activecell Address vemaju Excel VBA 2 January 4th, 2006 01:36 PM
HYPERLINK in activecell icayan Excel VBA 4 May 24th, 2005 12:22 PM
changing ActiveCell sedolphi Excel VBA 1 May 17th, 2004 02:37 PM





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