+ Reply to Thread
Results 1 to 4 of 4

Simple question about copying cells (?)

  1. #1
    Registered User
    Join Date
    03-26-2005
    Location
    Haarlem, the Netherlands
    MS-Off Ver
    Excel 2003, SP3
    Posts
    13

    Simple question about copying cells (?)

    Hi, maybe for you simple question - but not for me ....
    File A contains data for example in B8,C3,D4,E27,F33
    I wish to open a separate data-file B and copy the contents in the first empty row in cells with column number 1-5
    Managed to find a solution - a very ugly and inefficient one (every time read cell - open B - find first empty cell - copy contents - open A - read cell - open B - find first empty cell etc.)
    There certainly exists a faster/more elegant way.
    Who can/will help?
    Thanks, Kees

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    sorry but am confused...
    Can you post and example step by step?
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    It should be quicker to copy the 5 cells to variables, then open B, locate the first empty cell, and paste the remaining 4 as Offset(0,1) Offset(0,2) Offset(0,3) and Offset(0,4) to the first.

    ---


    Quote Originally Posted by Kees Korver
    Hi, maybe for you simple question - but not for me ....
    File A contains data for example in B8,C3,D4,E27,F33
    I wish to open a separate data-file B and copy the contents in the first empty row in cells with column number 1-5
    Managed to find a solution - a very ugly and inefficient one (every time read cell - open B - find first empty cell - copy contents - open A - read cell - open B - find first empty cell etc.)
    There certainly exists a faster/more elegant way.
    Who can/will help?
    Thanks, Kees

  4. #4
    Registered User
    Join Date
    03-26-2005
    Location
    Haarlem, the Netherlands
    MS-Off Ver
    Excel 2003, SP3
    Posts
    13
    Quote Originally Posted by stevebriz
    sorry but am confused...
    Can you post and example step by step?
    OK Steve, here it comes: (warning: I am not very proud about these programming lines ....)
    User enters values in non-contiguous cells in file JM.Meting
    After finishing he push button with this macro contained
    Macro will copy these values in another file JM.Data in cells A5:P5
    Thereafter the complete range B5:I5 is copied in *the first empty row > as a result JM.Data grows more and more to contain all user-data
    I think that these lines are not very efficient ....
    Any ideas to improve speed and efficiency?

    Sub Invoer()
    Workbooks.Open Filename:="C:\JM.Data.xls"
    Windows("JM.Meting.xls").Activate
    Application.ScreenUpdating = False
    Range("B5").Select
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("A5").Select
    Selection.Value = ""
    Range("B5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("B6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("C5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("E5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("D5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("E6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("E5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("F10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("F5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("B9").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("G5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("B10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("H5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("B11").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("I5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("F9").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("J5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("B3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("K5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("G12").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("L5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("JM.Meting.xls").Activate
    Range("B18").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("JM.Data.xls").Activate
    Range("M5:O5").Select
    Selection.Value = ""
    Range("P5").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Range("A5:P5").Select
    Selection.Copy
    Run ("VindLeeg")
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "XX"
    Application.ScreenUpdating = True
    Dim Msg, Style, Title
    Msg = "bla-bla"
    Style = vbInformation
    Title = "Datatransfer"
    Response = MsgBox(Msg, Style, Title)
    ActiveCell.Select
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1