Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Opening new excel file & inputting data into cells

I have this piece of code:

newfname = EDIFormP6.WeeklyOutputp6.Value & Format(Date, "dd.mm.yyyy")
& "TESTING" & ".xls"

Open newfname For Output As #1

Range("A1").Select
Cell_Contents = "UNS1"
Print #1, Cell_Contents

Selection.Offset(0.1).Select
Cell_Contents = "LIN1"
Print #1, Cell_Contents

Selection.Offset(0.1).Select
Cell_Contents = "NAD2A"
Print #1, Cell_Contents

close #1

Now, when i look at the excel file after the code has run, the UNS1,
LIN1 & NAD2A is appearing all in column A down 1 2 & 3, ive tried
various different codes which i would of thought would put them all in
row 1 columns A B & C but it just always seems to but them in all in
column A. am i missing something here?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Opening new excel file & inputting data into cells

On 16 Aug, 10:52, DJ MC wrote:
I have this piece of code:

newfname = EDIFormP6.WeeklyOutputp6.Value & Format(Date, "dd.mm.yyyy")
& "TESTING" & ".xls"

Open newfname For Output As #1

Range("A1").Select
Cell_Contents = "UNS1"
Print #1, Cell_Contents

Selection.Offset(0.1).Select
Cell_Contents = "LIN1"
Print #1, Cell_Contents

Selection.Offset(0.1).Select
Cell_Contents = "NAD2A"
Print #1, Cell_Contents

close #1

Now, when i look at the excel file after the code has run, the UNS1,
LIN1 & NAD2A is appearing all in column A down 1 2 & 3, ive tried
various different codes which i would of thought would put them all in
row 1 columns A B & C but it just always seems to but them in all in
column A. am i missing something here?


You are opening a file for output - fine, but that will create a text
file. The selection.offset is doing nothing as far as this code is
concerned apart from moving the cursor. My own preference would be to
reference the excel file and set the values as required but

Open newfname For Output As #1
Print #1, "UNS1", "LIN1","NAD2A"

close #1


will create a 3 column one row file for you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Opening new excel file & inputting data into cells

Hi, thanks for the reply
this puts all the data in cell A1 with a tab making it look like they
are in B & C, i actually need each piece of data in a different cell.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Opening new excel file & inputting data into cells

Do you really want an excel workbook file--or a text file with an extension of
..xls?

If you really want an excel file:

dim NewWks as worksheet
dim newFname as string

newfname = EDIFormP6.WeeklyOutputp6.Value & Format(Date, "dd.mm.yyyy") _
& "TESTING" & ".xls"

set newwks = workbooks.add(1).worksheets(1)
with newwks
.range("a1").value = "UNS1"
.range("B1").value = "LIN1"
.range("C1").value = "NAD2A"
.parent.saveas filename:=newfname, fileformat:=xlworkbooknormal
.close savechanges:=false
end with



DJ MC wrote:

I have this piece of code:

newfname = EDIFormP6.WeeklyOutputp6.Value & Format(Date, "dd.mm.yyyy")
& "TESTING" & ".xls"

Open newfname For Output As #1

Range("A1").Select
Cell_Contents = "UNS1"
Print #1, Cell_Contents

Selection.Offset(0.1).Select
Cell_Contents = "LIN1"
Print #1, Cell_Contents

Selection.Offset(0.1).Select
Cell_Contents = "NAD2A"
Print #1, Cell_Contents

close #1

Now, when i look at the excel file after the code has run, the UNS1,
LIN1 & NAD2A is appearing all in column A down 1 2 & 3, ive tried
various different codes which i would of thought would put them all in
row 1 columns A B & C but it just always seems to but them in all in
column A. am i missing something here?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
inputting data into excel to create csv file Paul Johnson Excel Discussion (Misc queries) 1 December 29th 08 02:31 PM
Alignment Data Label changes when opening file Excel 2007 moenli Charts and Charting in Excel 1 December 9th 08 06:45 PM
inputting figures in cells ray Excel Discussion (Misc queries) 1 September 30th 07 01:38 PM
open file by inputting file name in cell? Roger Abbot Excel Discussion (Misc queries) 1 September 15th 07 02:38 PM
Inputting duplicate data alert MS Excel 2003 qubit Excel Discussion (Misc queries) 2 January 25th 07 03:47 PM


All times are GMT +1. The time now is 09:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"