mrbcodc87
New Member
- Joined
- May 19, 2020
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
- MacOS
- Mobile
- Web
I Have two parts of code i need to put together and add too i need help with making at all work.
The first part of code selects cells D10 across to K10, copies it to another sheet i am using as a database in the last line of the sheet, then clears the original data i have copied from the sheet
Sub SaveLineData()
'
' SaveLineData Macro
'
'
Range("D10:K10").Select
Selection.Copy
Sheets("Database").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SCADA Entry Form").Select
Range("F10:K10").Select
Selection.ClearContents
End Sub
the second part of code needs to copy the data from cells D10 across to K10 to a text file along with the username of the use logged in running, then save the text file as the data from cell e10 to my network drive.
Sub Foo()
Dim wbSource As Workbook
Dim wsSource As Worksheet
Dim wbDest As Workbook
Dim fName As String
Dim TextFile As Integer
Dim FilePath As String
Set wbSource = ActiveWorkbook
Set wsSource = ActiveSheet
wsSource.Range("d10:k10").Copy
Shell "notepad.exe", vbNormalFocus
SendKeys "^V"
SendKeys "^{HOME}"
End Sub
I have got the code to open notepad and paste the cells but i am struggling to get it to write the user name, save as (data from e10) then close
if someone could combine these codes and help me finish what i am trying to do that would be great
thanks
The first part of code selects cells D10 across to K10, copies it to another sheet i am using as a database in the last line of the sheet, then clears the original data i have copied from the sheet
Sub SaveLineData()
'
' SaveLineData Macro
'
'
Range("D10:K10").Select
Selection.Copy
Sheets("Database").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SCADA Entry Form").Select
Range("F10:K10").Select
Selection.ClearContents
End Sub
the second part of code needs to copy the data from cells D10 across to K10 to a text file along with the username of the use logged in running, then save the text file as the data from cell e10 to my network drive.
Sub Foo()
Dim wbSource As Workbook
Dim wsSource As Worksheet
Dim wbDest As Workbook
Dim fName As String
Dim TextFile As Integer
Dim FilePath As String
Set wbSource = ActiveWorkbook
Set wsSource = ActiveSheet
wsSource.Range("d10:k10").Copy
Shell "notepad.exe", vbNormalFocus
SendKeys "^V"
SendKeys "^{HOME}"
End Sub
I have got the code to open notepad and paste the cells but i am struggling to get it to write the user name, save as (data from e10) then close
if someone could combine these codes and help me finish what i am trying to do that would be great
thanks