LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default How to using Address in selected Range

On Apr 3, 4:54*pm, FSt1 wrote:
hi
what problems are you having?
i see some syntax problems and i am not sure switching from offset(0,1) to
range("b"& row_value) will help?

Regards
FSt1

"moonhk" wrote:
Hi All


In below part of VBA, I am using offset to build k1 value. How to
using range("B" & row_value) *replace offset (0,1) ?


* *Dim rngToSearch As Range, rngToCheck As Range
* *Dim SchShtRange As String
* *Dim *SchShtName As String
* Dim k1 As String


* SchShtRange = "A1:A5"


* SchShtName = "RangeA"


* * Set rngToSearch = Sheets(SchShtName).Range(SchShtRange) 'change to
suit


* *For Each c In rngToSearch
* * * * If c.Value < "" Then
* * * * *k1 = c.Value + "|" & *c.Offset(0,1).Value
* * * * * * ...


.


I already define rngToSearch, how to using rngToSearch using .range(B
& row_value ) ?
It is because I want replace more then 20 columns. I want using range
rather than offset

Set rngToSearch = Sheets(SchShtName).Range(SchShtRange) 'change
to



Option Explicit
'~~ Class Modules : clsSch
Public schKey1
Public schKey2
Public schkey3

Sub Class_Initialize()
schKey1 = 0
schKey2 = "B"
schkey3 = 2
End Sub



Option Explicit
'~~ Class Modules : clsChk
Public chKey1
Public chKey2
Public chKey3

Sub Class_Initialize()
chKey1 = 0
chKey2 = 1
chKey3 = 2
End Sub



Sub Range_Update()

Dim objSch As New clsSch
Dim objChk As New clsChk
Dim rngToSearch As Range, rngToCheck As Range
Dim c, d, sName1 As String, sName2 As String
Dim found As Boolean
Dim NewCol As Integer
Dim k1 As String, k2 As String
Dim ChkShtName As String, SchShtName As String
Dim SchShtRange As String
Dim ChkShtRange As String

SchShtName = "RangeA"
ChkShtName = "RangeB"
SchShtRange = "A1:A5"
ChkShtRange = "A"

NewCol = 5
Set rngToSearch = Sheets(SchShtName).Range(SchShtRange) 'change to
suit
Set rngToCheck = Sheets(ChkShtName).Range("A1:" & ChkShtRange &
NewCol) 'change to suit

For Each c In rngToSearch
If c.Value < "" Then
k1 = c.Value + "|" & c.Offset(0, objSch.schKey2).Value + _
"|" + c.Offset(0, objSch.schkey3).Value
found = False
For Each d In rngToCheck
If d.Value < "" Then
k2 = d.Value + "|" & d.Offset(0, objChk.chKey2).Value
+ _
"|" + d.Offset(0, objChk.chKey3).Value
If k1 = k2 Then
'MsgBox k1
found = True
'~~ Other Value
d.Offset(0, 3).Value = c.Offset(0, 3).Value
Exit For
End If
End If
Next d
If found = False Then
NewCol = NewCol + 1
Set rngToCheck = Sheets(ChkShtName).Range("A1:" &
ChkShtRange & NewCol)
'~~Create Record
With Sheets(ChkShtName).Range(ChkShtRange & NewCol)
'~~ Key
.Value = c.Value
.Offset(0, objChk.chKey2) = c.Offset(0,
objSch.schKey2).Value
.Offset(0, objChk.chKey3) = c.Offset(0,
objSch.schkey3).Value
'~~ Other Value
End With

End If
End If
Next c

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Address of selected range vandenberg p Excel Programming 9 July 13th 08 09:41 PM
Lower right cell address in a selected range - Excel 2007 MSweetG222 Excel Programming 10 March 25th 08 04:43 PM
Get selected cell name/address David494 Excel Programming 5 August 1st 05 03:21 PM
How do I convert a selected Cell address in a Range to Values? MichaelC Excel Programming 2 June 10th 05 01:44 PM
How do you get a Selected Range address into a variable? Jack Excel Programming 5 November 20th 03 04:09 AM


All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"