Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

designate cells for Query

Status
Not open for further replies.

BSando

Technical User
Jun 29, 2003
73
AU
I want to specify a cell range in excel to paste a query too. I currently have code that I am using to add text to the spreadsheet such as formulas and labels.
Can anyone please help.

Thanks in advance

-----------------------------------

Dim mySheet As Object
Dim myBook As Object
Dim xlapp As Object

Set xlapp = Excel.Application

With xlapp
Workbooks.Open ("C:\3651H\monthlysales2.xls")

Set mySheet=Workbooks.Open("C:\3651H\Monthlysales2.xls").Sheets("Sheet1")
Sheets("sheet1").Name ([Forms]![monthly_report])
.Range("A1").Select
.ActiveCell.Value.Bold = "Date"
.Range("B1").Select
.ActiveCell.Value.Bold = "Store"
.Range("C1").Select
.ActiveCell.Value.Bold = "Product Code"
.Range("D1").Select
.ActiveCell.Value.Bold = "Sales (inc GST)"
.Range("C2").Select
.ActiveCell.FormulaR1C1 = "ABC-035 Total"
.Range("C3").Select
.ActiveCell.FormulaR1C1 = "AHJ-025 Total"
.Range("C4").Select
.ActiveCell.FormulaR1C1 = "AYB-1564 Total"


.Range("D2").Select
.ActiveCell.FormulaR1C1 = "=sum(Vlookup(""ABC-035"", C1:D549,2,FALSE))"
.Range("D3").Select
.ActiveCell.FormulaR1C1 = "=SUM(VLOOKUP(""AHJ-025"",C1:D549,2,FALSE))"
.Range("D4").Select
.ActiveCell.FormulaR1C1 = "=SUM(VLOOKUP(""AYB-1564"",C1:D549,2,FALSE))"

End With

xlapp.Quit

Set xlapp = Nothing

-------------------------------------

Some people make things happen, some watch while things happen, and some wonder 'What happened?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top