I'm trying to create a script that will write the value of a single cell to a text file. However, whenever I run this, I only see the values of A1. I would like to be able to write just the contents of B1. I'm screwing up on the range but not sure where. Any help would be very appreciated. Thanks in advance. I'm very new to this.
Option Explicit
Sub data_to_text_file()
Dim TextFile As Integer
Dim iCol As Integer
Dim myRange As Range
Dim cVal As Range
Dim i As Integer
Dim myFile As String
Set myRange = Range("B1")
iCol = myRange.Count
myFile = "C:\Users\...\Test3.txt"
TextFile = FreeFile
Open myFile For Output As TextFile
For i = 1 To iCol
Print #TextFile, Cells(1, i)
Next i
Close #TextFile
End Sub