Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Copy cells from one sheet to the next available row on another?

Hi Guys

I am trying to record a macro that will copy the information from one
row on one particular sheet (used daily) to the next available row on
another sheet.


Can anyone help. I'm fairly new at this but learning fast.


thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,073
Default Copy cells from one sheet to the next available row on another?

Hi clarkie,

You haven't supplied any details, so here's my way where the user makes
the decisions on the fly...

Public Sub RowToOtherSheet()
Dim rngDest As Range
Dim rngSubject As Range
Dim lngLastRow As Long
Dim lngLastColumn As Long

On Error GoTo CANCELLED 'handle Cancel press

'Row range to copy
Set rngSubject = Application.InputBox( _
prompt:="Select the leftmost cell of the row to copy.", _
Title:="Copy Row.", _
Default:=Selection.Address, _
Type:=8)
lngLastColumn = Cells(rngSubject.Row, _
Columns.Count).End(xlToLeft).Column
Set rngSubject = ActiveSheet.Range(rngSubject.Cells(1), _
Cells(rngSubject.Cells(1).Row, lngLastColumn))

'Sheet as destination
Set rngDest = Application.InputBox( _
prompt:="Click..." & vbNewLine & "1. Other sheet tab" & _
vbNewLine & "2. Any cell on that sheet" & vbNewLine & _
"3. OK", _
Title:="Destination?", _
Type:=8)

'Next available row on destination sheet relative to col A
With Worksheets(rngDest.Parent.Name)
lngLastRow = .Cells(Rows.Count, 1).End(xlUp).Row
Set rngDest = .Range(.Cells(lngLastRow, 1), _
.Cells(lngLastRow, rngSubject.Columns.Count))
End With

'transfer values
rngDest.Value = rngSubject.Value

'show that code has taken effect
'just delete next line if not necessary
Worksheets(rngDest.Parent.Name).Activate
CANCELLED:
End Sub


Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 45
Default Copy cells from one sheet to the next available row on another

Ken I have a variation of this task. I converted a pdf to xls and each page
is now a tab. I have a list with 4 columns that is 54 pages long now in 54
tabs. Can I use or modify this code to combine that list back into one tab?

I started to cut and paste and it's just taking too long. I have to run
analysis on this data and create pivots and charts. I will really like it if
I can get my list back into one tab.
--
Hile
Win2KPro
Office 2003

"Ken Johnson" wrote:

Hi clarkie,

You haven't supplied any details, so here's my way where the user makes
the decisions on the fly...

Public Sub RowToOtherSheet()
Dim rngDest As Range
Dim rngSubject As Range
Dim lngLastRow As Long
Dim lngLastColumn As Long

On Error GoTo CANCELLED 'handle Cancel press

'Row range to copy
Set rngSubject = Application.InputBox( _
prompt:="Select the leftmost cell of the row to copy.", _
Title:="Copy Row.", _
Default:=Selection.Address, _
Type:=8)
lngLastColumn = Cells(rngSubject.Row, _
Columns.Count).End(xlToLeft).Column
Set rngSubject = ActiveSheet.Range(rngSubject.Cells(1), _
Cells(rngSubject.Cells(1).Row, lngLastColumn))

'Sheet as destination
Set rngDest = Application.InputBox( _
prompt:="Click..." & vbNewLine & "1. Other sheet tab" & _
vbNewLine & "2. Any cell on that sheet" & vbNewLine & _
"3. OK", _
Title:="Destination?", _
Type:=8)

'Next available row on destination sheet relative to col A
With Worksheets(rngDest.Parent.Name)
lngLastRow = .Cells(Rows.Count, 1).End(xlUp).Row
Set rngDest = .Range(.Cells(lngLastRow, 1), _
.Cells(lngLastRow, rngSubject.Columns.Count))
End With

'transfer values
rngDest.Value = rngSubject.Value

'show that code has taken effect
'just delete next line if not necessary
Worksheets(rngDest.Parent.Name).Activate
CANCELLED:
End Sub


Ken Johnson


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
Copy certain cells from one sheet to another with a condition [email protected] Excel Worksheet Functions 1 January 3rd 07 11:08 PM
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
Asked previously...can this not be done in excel simonsmith Excel Discussion (Misc queries) 2 May 16th 06 11:50 PM
Copy 1 Sheet to Another Dar Excel Worksheet Functions 3 June 6th 05 10:52 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM


All times are GMT +1. The time now is 08:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"