How to export Excel data: from one sheet to another

How to export Excel data: from one sheet to another

Exporting data from one Excel spreadsheet to another spreadsheet is always a problem if you want to have the same content in the second too. We sill see how to solve this problem with an example.

Example 

I have a query. Whenever I export a file from the internet the data gets saved into a new Excel file instead of the Excel sheet I am working in. As a result I have to copy the data from that file to the Excel file I am working in. This is very time consuming. Is there a shorter method to directly export the data into the working Excel file?

Another example problem: I have recorded a macro for a particular worksheet. That macro does two things:

  • 1. There are two cols. Column A and Column B. In col C it subtracts Col A from B.
  • 2. It finds the weighted average between col A and C.

Now I want to run this macro in all worksheets except the first worksheet. What is the code to do that?

Solution

To solve the firs problem:

  • Copy the webpage address in Excel clipboard.
  • Go to your sheet.
  • Select any cell from where you want the file to be copied. e.g. A1.
  • Click data-import external data (or something like this depending upon the version) - new web query.
  • In the new web query window paste the address of the webpage at the top against "address".
  • Click on Go
  • You will get the whole webpage. Whatever table you want, click the tick mark and the whole table will be marked
  • Click "import" at the bottom right
  • It will ask where you want to park it. If it is already A1 click ok

To solve the second issue:

Sub test1()     
Dim j As Integer, k As Integer     
j = Worksheets.Count     
'MsgBox j     
For k = 1 To j     
'MsgBox Sheets(k).Name     
If Sheets(k).Name = "Sheet1" Then GoTo nnext     
Sheets(k).Activate     
NAME OF THE MACRO     
nnext:     
Next k     
End Sub
any more excel questions? Check out our forum!

Excel