Results 1 to 4 of 4

Thread: Thread linking question

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    2

    Thread linking question

    We have a series of worksheets, ex 4. On each work sheet (1,2,3) there is some information that I need to move onto work sheet 4.

    I need to take the info from Cells "A1" "F30" "E30" on work sheets 1-3 and paste them on work sheet 4 under "A" "B" and "C"

    I need to take the value (actual number), not formula, of "E30"

    This is what I have so far, any help would be appreciated.

    Code:
    Sub x()
    
    Dim ws As Worksheet
    Dim i As Integer
    
    Sheet4.Cells.Clear
    
    For i = 1 To 3
         Sheets(i).UsedRange.Range("A1").Copy Sheets("Total").Range("A" & Rows.Count).End(xlUp)(2)
         Sheets(i).UsedRange.Range("B4").Copy Sheets("Total").Range("B" & Rows.Count).End(xlUp)(2)
         Sheets(i).UsedRange.Range("D4").Copy Sheets("Total").Range("C" & Rows.Count).End(xlUp)(2)
    Next i
    
    End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Thread linking question

    no need to copy and paste, just assign the values
    vb Code:
    1. Sheets("Total").Range("A" & Rows.Count).End(xlUp)(2) = Sheets(i).UsedRange.Range("A1")
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    2

    Re: Thread linking question

    Quote Originally Posted by westconn1 View Post
    no need to copy and paste, just assign the values
    vb Code:
    1. Sheets("Total").Range("A" & Rows.Count).End(xlUp)(2) = Sheets(i).UsedRange.Range("A1")
    Thank you, but now for some reason it won't copy the contents of cells E30 and F30 (numbers) only of A1 (text).

    Also E30 and F30 are formulas consisting of Sum(E2:E29) and I would like to only copy the value in those two cells and not the formula. Do I need to use the 'pastespecial' command?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Thread linking question

    Do I need to use the 'pastespecial' command?
    there should be no need

    it should just copy the value, not the formula, i have tested here, works correctly
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width