No video

Excel VBA To Copy Data From One Sheet To Another (BEGINNER TO PRO!)

  Рет қаралды 102,835

Tiger Spreadsheet Solutions

Tiger Spreadsheet Solutions

Күн бұрын

How much time do you spend copying data from one sheet to another in Excel? It’s annoying, time-consuming … and prone to human error. It leaves you thinking: “there must be a better way …”
The good news: copying data in Excel from one sheet to another is what VBA absolutely loves! Even beginners can harness VBA to start moving data round.
In this video, I show you how to do this task at 5 levels of sophistication: from a simple one-line macro that an Excel beginner can use, to the actual mechanism I use on my projects to copy data from one sheet to another with Excel VBA. Are you ready to automate that time-consuming task? Let’s do this!
💻Download File Link
tinyurl.com/59...
💼Tiger Excel Basics - Rebuild Your Excel Foundation
www.tigersprea...
1. Basic A = B Operation
Let’s start with a basic A=B operation to get data moving around Excel using Excel VBA. The trick here is to remember which of A or B is the ‘destination’ (where the data ends up), and which is the ‘origin’ (where the data starts).
A (Destination) = B (Origin)
In this beginner Excel VBA construct, A is the destination and B the origin.
To translate this into Excel VBA:
Range(“B1”).value = Range(“A1”).value
copies the data from cell A1 into cell B1.
Next, try ‘stacking up’ multiple lines of code to perform multiple data transfer operations. All lines of code are executed as part of the same macro. Cool!
2. Basic A = B Operation Across Sheets
A small additional piece of code allows us to copy data between sheets. It’s as easy as:
Sheets(“Template”).Range(“D1”).value = _
Sheets(“Data”).Range(“A1”).value
Once again, try creating multiple lines of code to make the VBA routine even more useful. Note there is quite a lot of code accumulating in the VBA editor, now. Hhhmm …
Are you ready for a big step up in terms of difficulty … and power? I am going to introduce you to the actual mechanism I use to copy data from one sheet to another with Excel VBA. Let’s do this …
3. It would be perfect if we could control the data transfer … from a worksheet. That would avoid going into the VBA editor all the time and would make it easy to tweak or add to the data transfer.
We can do this with a table in the spreadsheet and a few supremely powerful lines of Excel VBA code.
Go ahead and create the 2-column table, or adapt the example in the download file.
Next: the supremely powerful line of Excel VBA code.
Warning: it’s a bit mind-bending! But the flexibility it creates is just awesome …
Range(Range(“C4”).Value).value = Range(Range(“C5”).value).value
Woah! What happened there?!
By embedding another cell reference within the usual Range(cell_address).value construct, we get Excel to read a cell input as a cell address. In other words, we control the origin and destination cells with cell inputs. Oh, yes! Punch the air …
By adding the sheet references, we can instantly copy data from one sheet to another using Excel VBA. And the process is controlled with worksheet cell inputs. Yes!
Sheets(“Template”).Range(Range(“G4”).Value).value = _
Sheets(“Data”).Range(Range(“H4”).Value).value
💼Tiger Excel Basics - Rebuild Your Excel Foundation
www.tigersprea...
4. Loop through the table
A loop allows us to do this with minimal additional code. Let’s use a ‘For Each’ loop to tell Excel to do something to each cell in the data transfer table, and use the .offset method to reference the cell to the right of the column we are looping through.
Dim Chris_Cell As Range
For Each Chris_Cell In Range(“G5:G7”)
Sheets(“Template”).Range(Chris_Cell.value).value = _
Sheets(“Data”).Range(Chris_Cell.offset(0,1).value).value
Next Chris_Cell
I’m counting 1,2,3 .. 4 lines of code. Yes, just four lines of code to transfer data from one sheet to another with Excel VBA. Why did I not try VBA earlier? I know!
5. Make the code dynamic (new entries)
Now, let’s take this solution to professional level. Things change in business, so an Excel VBA application should have the flexibility to respond to changes. Formulae and VBA should not be ‘hard-coded’; rather, we should aim for a ‘dynamic’ approach that can be quickly tweaked WITHOUT having to edit formulae or access the VBA editor.
It is possible with some advanced VBA. Hold tight!
Dim Chris_Cell As Range
For Each Chris_Cell In Range(Range(“G5”),Range(“G5”).end(xldown))
Sheets(“Template”).Range(Chris_Cell.value).value _
Sheets(“Data”).Range(Chris_Cell.offset(0,1).value).value
Next Chris_Cell
The result? A powerful, flexible, professional-level Excel VBA mechanism to copy data from one sheet to another in Excel.
💼Tiger Excel Basics - Rebuild Your Excel Foundation
www.tigersprea...

Пікірлер: 64
The Ultimate Guide to Copying Data using Excel VBA
31:05
Excel Macro Mastery
Рет қаралды 66 М.
VBA Macro to Copy Data from Another Workbook in Excel
13:39
Excel Campus - Jon
Рет қаралды 640 М.
Blue Food VS Red Food Emoji Mukbang
00:33
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 32 МЛН
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 4,3 МЛН
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 54 МЛН
WILL IT BURST?
00:31
Natan por Aí
Рет қаралды 40 МЛН
5 Excel Secrets You'll Be Embarrassed You Didn't Know
17:32
Excel Campus - Jon
Рет қаралды 181 М.
VBA to BROWSE & COPY Data from SELECTED File in Excel
10:00
Leila Gharani
Рет қаралды 328 М.
Excel Macros & VBA - Tutorial for Beginners
50:20
Kevin Stratvert
Рет қаралды 1,1 МЛН
Excel VBA: Copy Data Between ANY Two Sheets
12:56
Excel Macro Mastery
Рет қаралды 120 М.
Extract Data to Separate Sheets the Right Way!
8:34
MyOnlineTrainingHub
Рет қаралды 177 М.
10 Excel Formulas That Will Set You Apart (+Cheat Sheet)
18:04
MyOnlineTrainingHub
Рет қаралды 263 М.
Excel VBA to Save Data to Another Workbook
13:03
TeachExcel
Рет қаралды 64 М.
Blue Food VS Red Food Emoji Mukbang
00:33
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 32 МЛН