Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selective copying between sheets - Excel

Status
Not open for further replies.

jjefferson

Technical User
Oct 8, 2001
98
US
I have a workbook with one worksheet for each branch office; the name of the sheet is the branch code.

The last sheet in the workbook (called "DATA"), is a raw grid of data retrieved via SQL, and sorted in branch code order. Column A is the branch code, columns B to L have the rest of the data.

What I'd like to do is either row-by-row, or a selection of rows, copy columns B:L on the DATA sheet to columns A:K on the sheet bearing the branch's code. I don't care what happens to the DATA sheet during or after the process, if sequential destruction of values as they are copied is helpful.

The DATA sheet might look like this:
Code:
    A    B   C   D
1  ATL   1   2   3
2  ATL   1   2   3
3  HOU   1   2   3
4  NYC   1   2   3
5  NYC   1   2   3
So, I'd like to copy/move all the "ATL" entries to the sheet named "ATL", and so on. I'm stalled and even a firm conceptual shove would help a lot at this point.

Thanks!
 
Hi here you have 2 examples Redifine Range and Set Ranges.

Hope it helps

Public Sub CallRedefineRangeExample()
Dim rngRange As Word.Range
Dim strFindText As String

strFindText = InputBox("Enter the text you want to find.", _
"Redefine Range Example")
If Len(strFindText) = 0 Then Exit Sub
Set rngRange = RedefineRangeExample2(ActiveDocument, _
strFindText)
If Not rngRange Is Nothing Then
With rngRange
rngRange.Select
' Work with found Range object here.
End With
End If
End Sub


Sub SetRangeSamples()
Dim rngOne As Range

' Set Range equal to first three columns in
' Worksheets("Main").
Set rngOne = Range("A:C")
rngOne.Select
Stop

' Set Range equal to rows 3, 5, 7, and 9 in
' Worksheets("Main").
Set rngOne = Range("3:3, 5:5, 7:7, 9:9")
rngOne.Select

' Set Range equal to three noncontiguous cell
' groups in Worksheets("Main").
Set rngOne = Range("A1:C3, D5:G7, H2:J5")
rngOne.Select
End Sub Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top