Newbie question: Copy from two sheets and paste into another sheet in VBA

MizuHana

New Member
Joined
Feb 25, 2022
Messages
2
Office Version
  1. 365
Hi everyone! I am trying to learn some VBA stuff and I just couldn`t find any code that would help me with I am sure a very basic issue.
I need to take 3 columns from Sheet 1, paste it in Info Sheet starting at A1 and it will fill 3 columns to C.
Then I need to grab info from Sheet2 and paste in in the row A-C in the first open row.
Then I want it to become a table. I am just not sure how to connect all of this.
I would be very happy if someone could help. Thank you!

Sub OneCell()
Sheets("Sheet1").Select
Range("B:B, E:E, A:A").Copy
Sheets("Info").Select
Range("A:A").Select
ActiveSheet.Paste

Sheets("Sheet2").Select
Range("K:K, I:I, A:A").Copy
Sheets("Info").Select
Range("A:A").Select
ActiveSheet.Paste

Sub sbCreatTable()

'Create Table in Excel VBA
Sheet1.ListObjects.Add(xlSrcRange, Range("A1:D10"), , xlYes).Name = "myTable1"
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi, Can you kindly share a sample data through dropbox or drive. Thank you
 
Upvote 0
Sorry I can`t quite share any data but it is simple like this:
I wanna coppy A column, C column and F column to Info A column, B column, C column.
ABCDEFGH
BlaBlabBlablBlablaBlablabBlablablBlablablaBlablablab
ClaClaClaClaClaClaClaCla
 
Upvote 0
Hi
Kindly take backup of your data and try the following code. Please take note that I am also a newbie and learning as well. Kindly take a backup before trying the following code

VBA Code:
Sub Copy()
Application.ScreenUpdating = False
Dim ws1, ws2 As Worksheet
Dim lr, lr2 As Long
Dim Rngcpy, Rnginfo As Range

Set ws1 = ThisWorkbook.Sheets("Data")
Set ws2 = ThisWorkbook.Sheets("Info")

   With ws1
        lr = Range("A" & Rows.Count).End(xlUp).Row
        Set Rngcpy = Union(Range("A1:A" & lr), Range("C1:C" & lr), Range("F1:F" & lr))
    End With
        
    With ws2
        lr2 = ws2.Range("A" & Rows.Count).End(xlUp).Row
    End With
        If lr2 = 0 Then
        Set Rnginfo = ws2.Range("A1")
        Else
        Set Rnginfo = ws2.Range("A" & lr2 + 1)
        End If
        Rngcpy.Copy Rnginfo
        
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,544
Messages
6,120,126
Members
448,947
Latest member
test111

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top