#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default auto fill code

dim xlbook as excel.workbook
dim xlsheet as excel.worksheet
dim xlapp as excel.application
set xlapp = createobject ( " excel.application")
set xlbook = xlapp.workbook.add
set xlsheet = xlbook.xlsheet(1)
xlapp.visible = true
xlsheet.range("a1").value = 1000
xlsheet.range("b1").value = 200
xlsheet.range("c1").formula = xlsheet.range("a1").value -
xlsheet.range("b1").value
xlsheet.range("c2").formula = xlsheet.range("a2").value -
xlsheet.range("b2").value
'**********************
' actually column A and column b values were query values imported.

xlsheet.range("c1:c2").autofill ( xxlsheet.range("c1"):xlsheet.range("c25"))

' here im failing to autofill the formula for the range through code but
' i can with dragging the curser on the excel sheet on column C why ?
so it must be alike this,
a1=100 a2 = 200 a3 = 300
b1= 10 b2 = 0 c3 = 20
c1 = 110 c2 = 200 c3 = 320


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,489
Default auto fill code

Hi,

Try this modified code for the autofill.

xlsheet.Range("C1:C2").AutoFill Destination:=xlsheet.Range("C1:C25")

Cheers
Andy

balu wrote:
dim xlbook as excel.workbook
dim xlsheet as excel.worksheet
dim xlapp as excel.application
set xlapp = createobject ( " excel.application")
set xlbook = xlapp.workbook.add
set xlsheet = xlbook.xlsheet(1)
xlapp.visible = true
xlsheet.range("a1").value = 1000
xlsheet.range("b1").value = 200
xlsheet.range("c1").formula = xlsheet.range("a1").value -
xlsheet.range("b1").value
xlsheet.range("c2").formula = xlsheet.range("a2").value -
xlsheet.range("b2").value
'**********************
' actually column A and column b values were query values imported.

xlsheet.range("c1:c2").autofill ( xxlsheet.range("c1"):xlsheet.range("c25"))

' here im failing to autofill the formula for the range through code but
' i can with dragging the curser on the excel sheet on column C why ?
so it must be alike this,
a1=100 a2 = 200 a3 = 300
b1= 10 b2 = 0 c3 = 20
c1 = 110 c2 = 200 c3 = 320


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default auto fill code

dear sir
thanks for your advise , but still im not getting the right result my code
simply copying the first cell value into all the cells
kindly advise please


"Andy Pope" wrote:

Hi,

Try this modified code for the autofill.

xlsheet.Range("C1:C2").AutoFill Destination:=xlsheet.Range("C1:C25")

Cheers
Andy

balu wrote:
dim xlbook as excel.workbook
dim xlsheet as excel.worksheet
dim xlapp as excel.application
set xlapp = createobject ( " excel.application")
set xlbook = xlapp.workbook.add
set xlsheet = xlbook.xlsheet(1)
xlapp.visible = true
xlsheet.range("a1").value = 1000
xlsheet.range("b1").value = 200
xlsheet.range("c1").formula = xlsheet.range("a1").value -
xlsheet.range("b1").value
xlsheet.range("c2").formula = xlsheet.range("a2").value -
xlsheet.range("b2").value
'**********************
' actually column A and column b values were query values imported.

xlsheet.range("c1:c2").autofill ( xxlsheet.range("c1"):xlsheet.range("c25"))

' here im failing to autofill the formula for the range through code but
' i can with dragging the curser on the excel sheet on column C why ?
so it must be alike this,
a1=100 a2 = 200 a3 = 300
b1= 10 b2 = 0 c3 = 20
c1 = 110 c2 = 200 c3 = 320



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,489
Default auto fill code

Hi,

Try this.
The reason the value is being copied is your .Formula command was simply
storing the result of the calculation rather than the formula syntax.

Sub x()

Dim xlsheet As Worksheet

Set xlsheet = Sheet1

With xlsheet
.Range("a1").Value = 1000
.Range("b1").Value = 200
.Range("c1").Formula = "=" & _
.Range("a1").Address(False, False) & _
"-" & .Range("b1").Address(False, False)

.Range("C1:C1").AutoFill Destination:=.Range("C1:C25")
End With

End Sub

Cheers
Andy

balu wrote:
dear sir
thanks for your advise , but still im not getting the right result my code
simply copying the first cell value into all the cells
kindly advise please


"Andy Pope" wrote:


Hi,

Try this modified code for the autofill.

xlsheet.Range("C1:C2").AutoFill Destination:=xlsheet.Range("C1:C25")

Cheers
Andy

balu wrote:

dim xlbook as excel.workbook
dim xlsheet as excel.worksheet
dim xlapp as excel.application
set xlapp = createobject ( " excel.application")
set xlbook = xlapp.workbook.add
set xlsheet = xlbook.xlsheet(1)
xlapp.visible = true
xlsheet.range("a1").value = 1000
xlsheet.range("b1").value = 200
xlsheet.range("c1").formula = xlsheet.range("a1").value -
xlsheet.range("b1").value
xlsheet.range("c2").formula = xlsheet.range("a2").value -
xlsheet.range("b2").value
'**********************
' actually column A and column b values were query values imported.

xlsheet.range("c1:c2").autofill ( xxlsheet.range("c1"):xlsheet.range("c25"))

' here im failing to autofill the formula for the range through code but
' i can with dragging the curser on the excel sheet on column C why ?
so it must be alike this,
a1=100 a2 = 200 a3 = 300
b1= 10 b2 = 0 c3 = 20
c1 = 110 c2 = 200 c3 = 320



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
Auto-populate, Auto-copy or Auto-fill? Jay S. Excel Worksheet Functions 4 August 10th 07 09:04 PM
can I auto fill zip code column when city is typed Elsie C. Excel Worksheet Functions 1 September 28th 06 08:40 PM
using auto fill edit or fill handel fill handle or auto fill Excel Worksheet Functions 0 February 10th 06 07:01 PM
code to fill in missing border lines Jack Sons Excel Discussion (Misc queries) 3 November 3rd 05 10:06 PM
Can I auto fill a cell in one worksheet by typing a code number Gomer Pyle Excel Worksheet Functions 1 August 27th 05 01:24 AM


All times are GMT +1. The time now is 05:13 AM.

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

About Us

"It's about Microsoft Excel"