ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range in FindMethod? (https://www.excelbanter.com/excel-programming/282316-range-findmethod.html)

CG Rosén

Range in FindMethod?
 

Good Day,

Code below works OK. The problem is that the Range has to be optional
from DG5 DH5 DI5 DJ5 etc. Following seems not to work;
Set MyRange = Range("DG5")
With Sheets("tele").MyRange.CurrentRegion.Columns(1)

Thanks for any hints.

Brgds

CG Rosén
----------------------------------------------------------------------
Dim c
With Sheets("tele").Range("DG5").CurrentRegion.Columns( 1)

Set c = .Find(ComboBox1.Text, LookIn:=xlValues)
If c Is Nothing Then
.Cells(.Rows.Count + 1).Value = ComboBox1.Text
.Cells(.Rows.Count + 1).Offset(0, 1).Value = TextBox3.Text
Else
c.Offset(0, 1).Value = c.Offset(0, 1).Value + TextBox3.Text
End If

End With



Tom Ogilvy

Range in FindMethod?
 
It would only work if Tele is the activesheet when you do Set MyRange =
Range("DG5")

sStr = "DG5"

with worksheets("Tele").Range(sStr).CurrentRegion.Colum ns(1)

It is unclear how the appropriate cell will be specified.

--
Regards,
Tom Ogilvy

"CG Rosén" wrote in message
...

Good Day,

Code below works OK. The problem is that the Range has to be optional
from DG5 DH5 DI5 DJ5 etc. Following seems not to work;
Set MyRange = Range("DG5")
With Sheets("tele").MyRange.CurrentRegion.Columns(1)

Thanks for any hints.

Brgds

CG Rosén
----------------------------------------------------------------------
Dim c
With Sheets("tele").Range("DG5").CurrentRegion.Columns( 1)

Set c = .Find(ComboBox1.Text, LookIn:=xlValues)
If c Is Nothing Then
.Cells(.Rows.Count + 1).Value = ComboBox1.Text
.Cells(.Rows.Count + 1).Offset(0, 1).Value = TextBox3.Text
Else
c.Offset(0, 1).Value = c.Offset(0, 1).Value + TextBox3.Text
End If

End With






All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com