Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Get Data from One sheet to Other

Hi all, I have two Sheets in workbook. One sheet name is "Search" and
Other sheet name is "Data". In sheet "Data" I have data like (see
below)

A B C D---- columns
555360 XX1 12 XXZ4
555360 XX2 13 XDX5
555360 XX3 14 TYU4
555360 XX4 15 GHJ4
523600 GH5 16 ERT6
523600 GH6 17 XSE8
523600 GH7 18 FDS2
589632 ZR2 19 SDR9
589632 ZR3 20 HYU1
589632 ZR4 21 SEW1

In sheet "Search" I want macro on a button that when I put any number
of column A cells of sheet "Data" in Sheets("Search").Range("A1") then
by clicking the button macro should look that number in column A of
sheet "Data" and copy rows from column A to column D (not EntireRow)
of that number to sheet "Search" in Range("A6") to down. For exampe
if i put number "523600" in Range("A1") of sheet "Search" then when i
click button macro should look this number in column A of sheet "Data"
and copy rows from column A to D in sheet "Search" in Range("A6") to
down. The result will be somthing like this (see below)

A B C D---- columns
523600 GH5 16 ERT6
523600 GH6 17 XSE8
523600 GH7 18 FDS2

I hope I was able to explain my question. Can any friend can help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Get Data from One sheet to Other


Sub Search()
'
' Macro3 Macro
' Macro recorded 11/20/2008 by jwarburg
'

'
SearchRowCount = 1
With Sheets("Search")
DataRowCount = 1
Do While .Range("A" & SearchRowCount) < ""
SearchNum = .Range("A" & SearchRowCount)
With Sheets("Data")
First = True
DataRowCount = 1
Do While .Range("A" & DataRowCount) < ""
DataNum = .Range("A" & DataRowCount)
If DataNum = SearchNum Then
If First = True Then
.Range("A" & DataRowCount & ":D" & DataRowCount).Copy _
Destination:=Sheets("Search").Range("A" & SearchRowCount)
First = False
Else
.Range("A" & DataRowCount & ":D" & DataRowCount).Copy
Sheets("Search").Range("A" & (SearchRowCount + 1)).Insert
shift:=xlDown
SearchRowCount = SearchRowCount + 1
End If
End If
DataRowCount = DataRowCount + 1
Loop
SearchRowCount = SearchRowCount + 1
End With
Loop
End With
End Sub
"K" wrote:

Hi all, I have two Sheets in workbook. One sheet name is "Search" and
Other sheet name is "Data". In sheet "Data" I have data like (see
below)

A B C D---- columns
555360 XX1 12 XXZ4
555360 XX2 13 XDX5
555360 XX3 14 TYU4
555360 XX4 15 GHJ4
523600 GH5 16 ERT6
523600 GH6 17 XSE8
523600 GH7 18 FDS2
589632 ZR2 19 SDR9
589632 ZR3 20 HYU1
589632 ZR4 21 SEW1

In sheet "Search" I want macro on a button that when I put any number
of column A cells of sheet "Data" in Sheets("Search").Range("A1") then
by clicking the button macro should look that number in column A of
sheet "Data" and copy rows from column A to column D (not EntireRow)
of that number to sheet "Search" in Range("A6") to down. For exampe
if i put number "523600" in Range("A1") of sheet "Search" then when i
click button macro should look this number in column A of sheet "Data"
and copy rows from column A to D in sheet "Search" in Range("A6") to
down. The result will be somthing like this (see below)

A B C D---- columns
523600 GH5 16 ERT6
523600 GH6 17 XSE8
523600 GH7 18 FDS2

I hope I was able to explain my question. Can any friend can help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Get Data from One sheet to Other

Thanks Joel your code works perfectly fine. Just for my knowledge
that i created the macro see below

Sub srch()
Dim c As Range
Lcl = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
i = 6
For Each c In Sheets("Data").Range("A" & Lcl).Cells
If Range("A1").Value = c.Value Then
c.EntireRow.Copy Range("A" & i)
End If
i = i + 1
Next
End Sub

It has two problems
1 - at the moment its coping EntireRow but what code line i should add
in it that it should copy rows from column A to D
2 - at the moment its pasting only in row 6 but how can i make it to
paste row 6 to down.
your help will be much appricated. Thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Get Data from One sheet to Other


Sub srch()
Dim c As Range
Lcl = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
i = 6
For Each c In Sheets("Data").Range("A" & Lcl).Cells
If Range("A1").Value = c.Value Then
Range("A" & c.row & ":D" & c.Row).Copy Range("A6:A" & Ld)
End If
i = i + 1
Next
End Sub

"K" wrote:

Thanks Joel your code works perfectly fine. Just for my knowledge
that i created the macro see below

Sub srch()
Dim c As Range
Lcl = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
i = 6
For Each c In Sheets("Data").Range("A" & Lcl).Cells
If Range("A1").Value = c.Value Then
c.EntireRow.Copy Range("A" & i)
End If
i = i + 1
Next
End Sub

It has two problems
1 - at the moment its coping EntireRow but what code line i should add
in it that it should copy rows from column A to D
2 - at the moment its pasting only in row 6 but how can i make it to
paste row 6 to down.
your help will be much appricated. Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Get Data from One sheet to Other

On Nov 20, 4:03*pm, Joel wrote:
Sub srch()
Dim c As Range
Lcl = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
i = 6
For Each c In Sheets("Data").Range("A" & Lcl).Cells
If Range("A1").Value = c.Value Then
Range("A" & c.row & ":D" & c.Row).Copy Range("A6:A" & Ld)
End If
i = i + 1
Next
End Sub



"K" wrote:
Thanks Joel your code works perfectly fine. *Just for my knowledge
that i created the macro see below


Sub srch()
Dim c As Range
Lcl = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
i = 6
For Each c In Sheets("Data").Range("A" & Lcl).Cells
If Range("A1").Value = c.Value Then
c.EntireRow.Copy Range("A" & i)
End If
i = i + 1
Next
End Sub


It has two problems
1 - at the moment its coping EntireRow but what code line i should add
in it that it should copy rows from column A to D
2 - at the moment its pasting only in row 6 but how can i make it to
paste row 6 to down.
your help will be much appricated. *Thanks- Hide quoted text -


- Show quoted text -


Thanks lot joel


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate sheet, autonumber sheet, record data on another sheet des-sa[_2_] Excel Worksheet Functions 0 May 8th 08 06:56 PM
Hyperlinking from data in one sheet to matching data in another sheet Phrank Excel Worksheet Functions 6 December 18th 07 09:58 AM
Excel Macro for taking data external data and populating it on a sheet and deleting unwanted data [email protected] Excel Programming 3 November 8th 07 05:59 AM
Data copy from a seperate sheet to data sheet ZeroXevo Excel Programming 1 June 20th 05 08:14 AM
pull data from sheet two, then fill in the data to sheet one (part Jim Excel Worksheet Functions 3 December 11th 04 04:51 AM


All times are GMT +1. The time now is 09:52 AM.

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"