#1   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default VBA Help

Hi,
I got this formula that gives me the possibility to extract data when i type
a word, "K". This formula works but i need to put the extracted data to start
in second line, and i cant, i changed where is "H" to many numbers and didn't
make the effect that i want. Someone can help me?
Other thing, with this formula i can control with "C" in wich row it starts
the extracted data of that line to Sheet2, but if i want just some row and
not the whole line, for example i want the rows C, D, E, U, only and not the
whole line, what do i need to change in the whole formula.

Sub comlin3()
For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, "B").Value = "K" Then
iRow = iRow + 1
Cells(i, "C").Resize(, 10).Copy Worksheets("Sheet2").Range("H" &
iRow)
End If
Next i
End Sub

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default VBA Help

I forgot to ask, can i make a macro in sheet1 to clean sheet2 if i need? This
macro with a security asking if really want to erase f.e.

Thanks Again
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default VBA Help

dim resp as long
resp = msgbox(Prompt:="Do you want to clean sheet2?",buttons:=vbyesno)
if resp = vbyes then
worksheets("sheet2").cells.clearcontents 'or whatever you mean
end if

might be one way???

Micos3 wrote:

I forgot to ask, can i make a macro in sheet1 to clean sheet2 if i need? This
macro with a security asking if really want to erase f.e.

Thanks Again


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default VBA Help

Maybe...

Sub comlin3()
dim i as long
dim nextrow as long

with activesheet
For i = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row
If .Cells(i, "B").Value = "K" Then
with worksheets("sheet2")
nextrow = .cells(.rows.count,"A").end(xlup).row + 1
end with
.Cells(i, "C").Resize(, 10).Copy _
Worksheets("Sheet2").Range("H" & nextrow)
End If
Next i
end with
End Sub

I used column A in Sheet2 to find the next available row. Change that to a
column that always has data.

Micos3 wrote:

Hi,
I got this formula that gives me the possibility to extract data when i type
a word, "K". This formula works but i need to put the extracted data to start
in second line, and i cant, i changed where is "H" to many numbers and didn't
make the effect that i want. Someone can help me?
Other thing, with this formula i can control with "C" in wich row it starts
the extracted data of that line to Sheet2, but if i want just some row and
not the whole line, for example i want the rows C, D, E, U, only and not the
whole line, what do i need to change in the whole formula.

Sub comlin3()
For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, "B").Value = "K" Then
iRow = iRow + 1
Cells(i, "C").Resize(, 10).Copy Worksheets("Sheet2").Range("H" &
iRow)
End If
Next i
End Sub

Thanks


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default VBA Help

IThanks 'll gonna try now till work, i'll tell anything later.

Thank u!!!


  #6   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default VBA Help

The clean up sheet is Wonderfull, it works just fine!
The other macro, it really goes to 2nd line, if i write in 2nd line it goes
to 3rd. It's fine, but the problem is that only goes the last line of "K".
If i have many "K", only the last one goes to the Sheet2.
And the most difficult, pic rows, is it possible?

Thanks :)
  #7   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default VBA Help

I don't think I understand your question...

But if you can pick out the column that always has data, you can change this
area:

with worksheets("sheet2")
nextrow = .cells(.rows.count,"A").end(xlup).row + 1
end with

Change that "A" to the column that always has data.

Micos3 wrote:

The clean up sheet is Wonderfull, it works just fine!
The other macro, it really goes to 2nd line, if i write in 2nd line it goes
to 3rd. It's fine, but the problem is that only goes the last line of "K".
If i have many "K", only the last one goes to the Sheet2.
And the most difficult, pic rows, is it possible?

Thanks :)


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default VBA Help

Sorry i didn't tell nothing in weekend but with no net.....

I didn't knew of that trick :)
i thought that "A" had relation only to the sheet!!!
So with your anwser I tryed with other letters and with "B", it worked just
fine, so other problem solved :D

To explain better the last problem, with example that is simpler:
A B C D E
1 12-05 K Suplier 10‚¬ 0
2 12-05 Y Suplier 0 5‚¬
3 13-05 W Suplier 0 15‚¬
4 14-05 K Suplier 7,5‚¬ 0
With your solution, that works good, in sheet2 it would appear all rows
after "C", for example, but i want to appear only row C and D in sheet2.
This was the other problem that i named as pic rows.
Is it possible?

Thanks a lot
  #9   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default VBA Help

I want to choose the picked rows or limit to which row i want to copy to
other sheet, because i want to write other things in principal sheet that i
didn't wanted to appear in other sheet.

Now i think that i'm ready to make the program complete. If u want i can
send u a copy, to see the purpous for.

Many Thanks
Reply
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



All times are GMT +1. The time now is 07:25 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"