Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Totally Stuck...Help Please!

Hi there,

I will give you some context. Here is the process i am trying to accomplish:

1. External site creates a log entry
2. That entry is a) copied to last empty row in site log, and b) copy and
pasted to new workbook (you helped me with this part)
3. The new workbook is to be named, ex 'Cop Export 1'
4. Each time step 2 is run, the 'Cop Export 1' workbook can be overwritten,
as it is a temporary tool used as a data vehicle
5. The new workbook 'Cop Export 1' is emailed to head quaters
5. Head quaters user runs an import script which grabs the data sent in the
'Cop Export 1', and pastes ithe last row only t to the last empty row of the
head quaters master log.

Make sense?

Questions:

1) How can i name the newly created workbook which copies the first and
last row?
2) How can I import the data row of 'Cop Export 1' workbook to the head
quarters master log?


Thank you so much for your patience, and especially, your time
--
Carlee


"JLatham" wrote:

Well, yes it is, but remember that then you'd constantly be overwriting the
existing Copreco Reading.xls file with the new one, if that's your intent,
then might be easier just to open the existing "Copreco Reading.xls" workbook
and overwrite the 2nd row of data.

"Carlee" wrote:

In your first miracle, is it possible to save the new workbook created as
"Copreco Reading"
--
Carlee


"JLatham" wrote:

Glad the first wand-wave worked. Now, I presume that we are now dealing with
copying row 2 from the new workbook, where we just copied the heading row and
one row of data into (Sheet1) and are now going to copy that to yet a 3rd
workbook?

If that's the case we can modify the previous code just a little to see if
that other workbook is open, open it if it isn't, find a specific sheet in it
and take what we pasted into row 2 of the new book into the last row on the
sheet in your master book. While I'm dealing with that, I'll wait for your
response to this. Got a couple of VERY hot irons in the fire right now, so I
can deal with those until I get notice you've replied and then I can put the
code together properly for you.

"Carlee" wrote:

This worked beautifully. Now...I have yet another issue...

This new book and data, I have created (thanks to you) will be sent via
email to a user. I need to be able to extract the data sent (minus column
headings) and import it into the last line of a master file.

Can you wave your magic wand, once again?

--
Carlee


"JLatham" wrote:

First thing I see is that the With Sheets() instruction has a different sheet
name than you mention in your description. That sheet name should be the
actual name of the sheet that your source data is on. You would also need a
sheet named sheet16 in the workbook for it to function properly.

But this all takes place in the same workbook, not between two separate
workbooks (.xls files).

The code here will copy 1st and last row of data on a sheet to Sheet1 in a
new workbook. It works to some degree because we know that in a new workbook
there is always a sheet named "Sheet1" and that any sheet has a row 1 and a
row 2. I show this code within a regular Sub declaration, but you could copy
the code between Sub ... and End Sub and replace the code in your
Button2_Click routine with it. It works based on Button2 being in the same
workbook with the source data.

Where you see an instruction end with " _" it means that the instruction
continues on the next row. Don't worry - Excel will deal with it just fine.
I just wanted you to know what it means.

Two things that may need changing: the Const sourceSheet should be set to =
the exact name of the sheet that you want to copy row 1 and last row from.
Later in the code where you see "A" - change that (if needed) to refer to a
column that will always have information in that last row so that the program
can find it. That line of code will find the last cell in the referenced
column with information in that column.

Sub CopyToNewWorkbook()
Const sourceSheet = "Site Master Log" ' change??
Dim sourceBook As String
Dim destBook As String
Dim sourceRange As Range
Dim destRange As Range

Application.ScreenUpdating = False
sourceBook = ThisWorkbook.Name
Workbooks.Add ' create new book
destBook = ActiveWorkbook.Name
Windows(sourceBook).Activate
Worksheets(sourceSheet).Select

Set sourceRange = ActiveSheet.Rows("1:1")
Set destRange = Workbooks(destBook).Worksheets( _
"Sheet1").Rows("1:1")
destRange.Value = sourceRange.Value
'change "A" to column with data in last row
Range("A" & Rows.Count).End(xlUp).Select
Set sourceRange = ActiveSheet.Rows( _
ActiveCell.Row & ":" & ActiveCell.Row)
Set destRange = Workbooks(destBook).Worksheets( _
"Sheet1").Rows("2:2")
destRange.Value = sourceRange.Value
Set sourceRange = Nothing
Set destRange = Nothing
End Sub



"Carlee" wrote:

Hi there,
I am pretty new to MS Excel, but this is what i want to do. I have asked
for help on this already, but haven't had much luck. I apprevciate everyones
patiences.

I have a 'Site Master Log' sheet which contains site readings. There are
many site readings.

I want to be able to click a button on my user form and have the last row of
'Site Master Log' copied (including column headers) and pasted into new
workbook. This new workbook will be used as an attachment for a subsequent
email.

The code i was given (see below) stated the 'subscript was out of range',
but i don't know what that means.

Thanks for your help

Sub Button2_Click()
With Sheets("Site Reading Log") 'source
.Rows(.Cells(Rows.Count, "a").End(xlUp).Row).Copy Sheets("sheet16").Rows(1)
'destination

End With


End Sub

--
Carlee

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
Totally confused - please help! James Excel Worksheet Functions 3 April 14th 08 10:23 PM
Totally wierd Fritz Excel Worksheet Functions 4 July 23rd 07 01:44 PM
Totally Stumped Sondra Excel Discussion (Misc queries) 3 February 15th 06 02:01 PM
totally newbie to VBA need help cuongvt Excel Programming 1 September 29th 05 06:24 AM
Highlighting blanks via GO TO SPECIAL is not highlighting blank cells - HELP, I'm totally stuck. Jamie Furlong Excel Discussion (Misc queries) 6 August 28th 05 09:27 PM


All times are GMT +1. The time now is 07:20 PM.

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"