View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Andreas Andreas is offline
external usenet poster
 
Posts: 20
Default How to interpret my code

hmmm. I cannot reach him as he's on holiday... any chance you have an idea of
how to write (and of course have time to) code that could help me, I'll
attach the whole code for the button below, but basically what I want to do
is, when pushing the button in one sheet, to copy data from 5 sheets (all
sheets are standardised) from c6:o6 to the last row which might change
depending on how many rows the input data have. Take all the rows from the
five sheets and paste into an exactly the same sheet as the others, one
problem is obvious that the numbers of rows can be different so the macro
must be flexible in where to paste in the code.

I understand if you dont have time but I would highly higlhy appreciate
it.......

"Tom Ogilvy" wrote:

half your variables are undefined in the macro. So they should be raising
errors. Such as

With LwkbkSource

is isn't assigned a reference in this code, so know way to know what it
refers to or even if it works for you.

You need to go back to the "giver" of the code and ask questions of that
person.

--
Regards,
Tom Ogilvy




"Andreas" wrote:

I have been given some code that should worl to get information from five
standardised docs till a new similar doc. However, as the code given is not
perfectly fitted to my doc I have trouble in getting the code work for me.
The code is (this is not all data for the process but only the data that does
not work:

private Sub GetData(LsWorkbook As String)

Dim LrDestRange As Range
Dim LrSourceRange As Range
Dim LlCounter As Long
Dim LwkbkSource As Workbook
Dim LrRange As Range
Dim LsFileFolder As String






' First Check that the format of the data is correct

With LwkbkSource.Sheets(1)
Set LrSourceRange = .Range(.Range("A1"), .Range("A1").End(xlToRight))
End With

For Each LrRange In SData.Range("Headings")

If LrRange.Offset(-1, 0).Value = "Check" Then

If Not LrSourceRange.Cells(LrRange.Column).Value = LrRange.Value Then

MsgBox "Source data is missing column " & LrRange.Column & ", value
= " & LrRange.Value

End

End If

End If

Next

' Passed the checks so paste in the data

Set LrDestRange = SData.Range("A1").End(xlDown).Offset(1, 0)

With LwkbkSource.Sheets(1)
Set LrSourceRange = .Range(.Range("A2"),
.Range("A2").End(xlDown).Offset(0, SData.Range("Headings").Columns.Count))
End With

LrDestRange.Resize(LrSourceRange.Rows.Count,
LrSourceRange.Columns.Count).Value = LrSourceRange.Value

LrDestRange.Offset(0, LrSourceRange.Columns.Count -
1).Resize(LrSourceRange.Rows.Count, 1).Value = LsWorkbook

LwkbkSource.Close

Exit Sub


So what I want to be able to do is to get my five tabs with information,
A,B,C,D,E to get copied and pasted in the new document below eachother. The
new document is called X. The thing is that the array I want to copy is from
c6:O6 and all the way down until the last row which can fluctuate. So as I
see it the code must be changed for that as well...

What other things must I do to get it to work??? for example

With LwkbkSource.Sheets(1)

what does that mean, must I change Sheets(1) for something???

I would like to keep as close to the original codeas possible, but could
anyone see and tell me what changes I need to do????