ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change macro (https://www.excelbanter.com/excel-programming/325604-change-macro.html)

Alen32

change macro
 
I want to change this macro so result isn't in listbox but on sheet1
starting with cell E1.
Private Sub UserForm_Initialize()
Dim cell As Range
Dim sh As Worksheet

With Me
.ListBox1.RowSource = ""
.ListBox1.ColumnCount = 3
.ListBox1.Clear
End With

Set sh = Worksheets("Ark1")

For Each cell In sh.Range("A10:A250")
If cell.Value = sh.Range("A5").Value Then
With UserForm1
.ListBox1.AddItem cell.Value
.ListBox1.List(.ListBox1.ListCount - 1, 1) _
= cell.Offset(0, 2).Value
.ListBox1.List(.ListBox1.ListCount - 1, 2) _
= cell.Offset(0, 5).Value
End With
End If
Next

End Sub




Bob Phillips[_6_]

change macro
 
Private Sub UserForm_Initialize()
Dim cell As Range
Dim sh As Worksheet
Dim sh1 As Worksheet
Dim i As Long

Set sh = Worksheets("Ark1")
Set sh1 = Worksheets("Sheet1")

i = 1
For Each cell In sh.Range("A10:A250")
If cell.Value = sh.Range("A5").Value Then
With sh1
.Cells(i,"A").Value = cell.Value
.Cells(i,"B").Value = cell.Offset(0, 2).Value
.Cells(i,"C").Value = cell.Offset(0, 5).Value
i = i + 1
End With
End If
Next

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I want to change this macro so result isn't in listbox but on sheet1
starting with cell E1.
Private Sub UserForm_Initialize()
Dim cell As Range
Dim sh As Worksheet

With Me
.ListBox1.RowSource = ""
.ListBox1.ColumnCount = 3
.ListBox1.Clear
End With

Set sh = Worksheets("Ark1")

For Each cell In sh.Range("A10:A250")
If cell.Value = sh.Range("A5").Value Then
With UserForm1
.ListBox1.AddItem cell.Value
.ListBox1.List(.ListBox1.ListCount - 1, 1) _
= cell.Offset(0, 2).Value
.ListBox1.List(.ListBox1.ListCount - 1, 2) _
= cell.Offset(0, 5).Value
End With
End If
Next

End Sub






Alen32

change macro
 
Thanks Bob!
What I need to change if I want to display results starting with cell F10.


Bob Phillips[_7_]

change macro
 
This line

For Each cell In sh.Range("A10:A250")

and maybe this line?

If cell.Value = sh.Range("A5").Value Then


--
HTH

Bob Phillips

"Alen32" wrote in message
lkaboutsoftware.com...
Thanks Bob!
What I need to change if I want to display results starting with cell F10.




Alen32

change macro
 
I think you misunderstod me. I want to display results starting with cell
F10.
I tried this but doesn't work
from
.Cells(i,"A").Value = cell.Value
to thix
.Cells(i,"F10").Value = cell.Value


Bob Phillips[_6_]

change macro
 
Private Sub UserForm_Initialize()
Dim cell As Range
Dim sh As Worksheet
Dim sh1 As Worksheet
Dim i As Long

Set sh = Worksheets("Ark1")
Set sh1 = Worksheets("Sheet1")

i = 10
For Each cell In sh.Range("A10:A250")
If cell.Value = sh.Range("A5").Value Then
With sh1
.Cells(i,"F").Value = cell.Value
.Cells(i,"G").Value = cell.Offset(0, 2).Value
.Cells(i,"H").Value = cell.Offset(0, 5).Value
i = i + 1
End With
End If
Next

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I think you misunderstod me. I want to display results starting with cell
F10.
I tried this but doesn't work
from
.Cells(i,"A").Value = cell.Value
to thix
.Cells(i,"F10").Value = cell.Value




Alen32

change macro
 
Now results are in cell F1,G1 and H1.
I want result in F10,G10 and H10


Bob Phillips[_6_]

change macro
 
Should be F10, I initialised i to 10.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
Now results are in cell F1,G1 and H1.
I want result in F10,G10 and H10




Alen32

change macro
 
It works Thank you very much!



All times are GMT +1. The time now is 05:01 PM.

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