Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Syntax with copy down and copying a block

Posted on 2006-07-17
3
Medium Priority
?
157 Views
Last Modified: 2010-04-30
Excel VBA

I am trying to
1) copy D25 and copy down where Column E data ends
2) Then Copy start in D25 through Column J where data ends
 And put into a new worksheet starting A1.  
           D           E            F           G      H            I        J
25      2805      11111     11111      1111      1111       111    111      
26                   11111     11111      1111      1111       111    111      
27                  11111     11111      1111       1111      111    111      
 
I am having trouble with syntax of the following piece of code.

Dim r
  r = Range("E65536").End(xlUp).Row
  Range("D25").Resize(r, 1).FillDown

Set rngToCopy = Sheets("Data input sheet").Cells(Rows.Count, "D").End(xlUp).Offset(25, 4)

Any help would greatly be appreciated!

Here is the full piece
///////////////////////////////////////////////////////////
Private Sub cmdTransferToSRP_Click()
'Copy Data and transfer to New Workbook
Dim rngToCopy As Range
Dim rngToPaste As Range

Dim r
  r = Range("E65536").End(xlUp).Row
  Range("D25").Resize(r, 1).FillDown

Set rngToCopy = Sheets("Data input sheet").Cells(Rows.Count, "D").End(xlUp).Offset(25, 4)
   
'Open new workbook to create text file

Workbooks.Add
rngToCopy.Copy
ActiveSheet.Paste


    Application.CutCopyMode = False
   
    Sheets("Sheet3").Select
    ActiveWindow.SelectedSheets.Delete
   
    Sheets("Sheet2").Select
    ActiveWindow.SelectedSheets.Delete
   
 Application.CutCopyMode = False
   
   
0
Comment
Question by:ca1358
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:ca1358
ID: 17125173
Ok got the rngToCopy to work.

Set rngToCopy = Range("D25:J" & Cells(Rows.Count, "D").End(xlUp).Row)

Now need to figure out
Test Data right now is D25:J37 with D25 having on "2805" and D26 on down blank but when I run the code for some reason the "2805" in D25 is copying down to D61 and not stop in D37.  Can someone tell me why?


Dim r
  r = Range("E65536").End(xlUp).Row
  Range("D25").Resize(r, 1).FillDown
0
 

Author Comment

by:ca1358
ID: 17131067
Here is the answer- you can close this.  

Dim r
  r = Range("E65536").End(xlUp).Row
  Range("D25:D" & r).FillDown


Set rngToCopy = Range("D25:J" & Cells(Rows.Count, "D").End(xlUp).Row)


Thank you.
0
 

Accepted Solution

by:
EE_AutoDeleter earned 0 total points
ID: 17279613
ca1358,
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

EE_AutoDeleter
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question