Please give an explicit example. I.e. a hand-worked-out from and to range,
including a description of the human logic you needed to follow to find both
the source range and the destination position. It is not possible to tell
from your code what you were actually intending to do, nor from your too
brief explanation in your latest message.
Regards, Dave S
----- Original Message -----
From: "Baljeet Bilkhu" <baljeet_bilkhu@yahoo.ca>
To: <ExcelVBA@yahoogroups.com>
Sent: Friday, June 17, 2011 3:11 AM
Subject: Re: [ExcelVBA] Copying Data from a Range
Hi,
I'm actually trying to copy a formula from a range of cells to the next,
blank range of cells. The first row of this spreadsheet has the date all
across and every day, I would like to run this macro that would copy a
formula from the previous day and put it in the next available blank cells.
--- On Thu, 6/16/11, David Smart <smartware.consulting@gmail.com> wrote:
From: David Smart <smartware.consulting@gmail.com>
Subject: Re: [ExcelVBA] Copying Data from a Range
To: ExcelVBA@yahoogroups.com
Received: Thursday, June 16, 2011, 11:17 AM
Source range appears to be just one cell.
LcS is made up from
UsedRange.Column which will be the right hand column number
UsedRange.Columns.Count which will depend on which columns are actually
being used, I think
minus 1.
But you then use LcS as a row number !!
Similarly for LcD. You're doing a calculation based on columns, but then
using it as a row number.
And you're only copying one cell anyway, so the chances are that it doesn't
have anything in it.
What actually are you trying to do?
Regards, Dave S
----- Original Message -----
From: "Baljeet Bilkhu" <baljeet_bilkhu@yahoo.ca>
To: <ExcelVBA@yahoogroups.com>
Sent: Friday, June 17, 2011 12:48 AM
Subject: [ExcelVBA] Copying Data from a Range
Hi,
I'm trying to copy data within a particular range using the following code,
but when I run it, no data is being copied:
Sub Copy_Daily()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, SourceSheet As Worksheet, LcD As Long, LcS As
Long
Dim LastColumn As Integer
With Application
..ScreenUpdating = False
..EnableEvents = False
End With
Set SourceSheet = Sheets("Daily Comp Count")
LcS = SourceSheet.UsedRange.Column - 1 + SourceSheet.UsedRange.Columns.Count
Set SourceRange = Sheets("Daily Comp Count").Range("O" & LcS)
Set DestSheet = Sheets("Daily Comp Count")
LcD = DestSheet.UsedRange.Column + 1 + SourceSheet.UsedRange.Columns.Count
Set DestRange = DestSheet.Range("P" & LcD)
SourceRange.Copy
DestRange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
With Application
..ScreenUpdating = True
..EnableEvents = True
End With
End Sub
Basically what I'm trying to do is to:
Can anyone help with this.
[Non-text portions of this message have been removed]
------------------------------------
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
here: http://www.mousetrax.com/techtrax to enter the ezine, then search the
ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------Yahoo! Groups Links
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1382 / Virus Database: 1513/3707 - Release Date: 06/16/11
[Non-text portions of this message have been removed]
------------------------------------
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
here: http://www.mousetrax.com/techtrax to enter the ezine, then search the
ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------Yahoo! Groups Links
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1382 / Virus Database: 1513/3707 - Release Date: 06/16/11
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar