I have a google sheet open in my Chrome browser on my PC. The goole sheet name is…
- User
I have a google sheet open in my Chrome browser on my PC. The goole sheet name is 'Current Jobs'. I also have an Excel workbook 'Premesis Requests' open on my PC. I want to write a vba code that will copy columns A to Columns J from the google sheet page 'Current Jobs' and then paste the column's to my Excel workbook 'Premises Request' in the sheet named 'Paste' and also into the same columns A to columns J.
- Assistant
As an AI language model, I cannot access your computer and files. However, here's a sample VBA code that you may modify as per your requirement:
Sub copyToExcel() Dim sourceSheet As Worksheet Dim targetSheet As Worksheet 'This line opens the Google Sheet in the default browser - enter the URL of your Google Sheet Dim mySheetURL As String: mySheetURL = "https://docs.google.com/spreadsheets/d/123456/edit#gid=0" ThisWorkbook.FollowHyperlink mySheetURL 'This line gets the "Current Jobs" sheet Set sourceSheet = ActiveWorkbook.Worksheets("Current Jobs") 'This line selects the columns to copy sourceSheet.Range("A:J").Select 'This line copies the selected columns Selection.Copy 'This line opens the Excel workbook where you want to paste the data - enter the path and name of your workbook Set targetSheet = Workbooks.Open("C:\Users\Username\Documents\Premises Request.xlsx").Worksheets("Paste") 'This line selects the starting cell where you want to paste the data - adjust as per your requirement targetSheet.Range("A1").Select 'This line pastes the copied data in the same columns A to J of 'Paste' worksheet targetSheet.PasteSpecial 'This line closes the Google Sheet ActiveWorkbook.Close SaveChanges:=False 'This line saves your changes in the Excel workbook ActiveWorkbook.Save End Sub - User
The chrome browser is already open and displaying the google sheet. The excel workbook 'Premises Requests' is also open too. can I write a code that takes these into account
- Assistant