Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Can someone assist with the correct structure for the following: Dim The_Sheet As ?????????????? Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = .Range("A1") Application.Goto Sheets("Data").Range("A1") & Sheets("Data").Range("A1").Offset(0, col).Value = MyDatabase.Fields (col).Name I want to replace the code 'Sheets("Data").Range("A1")' with the variables. Andrew 150208 -- Andrew |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim The_Sheet As Worksheet
Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = The_Sheet.Range("A1") Application.Goto The_Range The_Range.Offset(0, col).Value = MyDatabase.Fields(col).Name But there's no reason to use the application.goto line. Andrew wrote: Hi, Can someone assist with the correct structure for the following: Dim The_Sheet As ?????????????? Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = .Range("A1") Application.Goto Sheets("Data").Range("A1") & Sheets("Data").Range("A1").Offset(0, col).Value = MyDatabase.Fields (col).Name I want to replace the code 'Sheets("Data").Range("A1")' with the variables. Andrew 150208 -- Andrew -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think you need some set statements:
Set The_Sheet = Sheets("Data") Set The_Range = The_Sheet.Range("A1") "Dave Peterson" wrote: Dim The_Sheet As Worksheet Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = The_Sheet.Range("A1") Application.Goto The_Range The_Range.Offset(0, col).Value = MyDatabase.Fields(col).Name But there's no reason to use the application.goto line. Andrew wrote: Hi, Can someone assist with the correct structure for the following: Dim The_Sheet As ?????????????? Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = .Range("A1") Application.Goto Sheets("Data").Range("A1") & Sheets("Data").Range("A1").Offset(0, col).Value = MyDatabase.Fields (col).Name I want to replace the code 'Sheets("Data").Range("A1")' with the variables. Andrew 150208 -- Andrew -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yep.
Thanks for the correction. (Copy and paste is bad...very bad!) JMB wrote: I think you need some set statements: Set The_Sheet = Sheets("Data") Set The_Range = The_Sheet.Range("A1") "Dave Peterson" wrote: Dim The_Sheet As Worksheet Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = The_Sheet.Range("A1") Application.Goto The_Range The_Range.Offset(0, col).Value = MyDatabase.Fields(col).Name But there's no reason to use the application.goto line. Andrew wrote: Hi, Can someone assist with the correct structure for the following: Dim The_Sheet As ?????????????? Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = .Range("A1") Application.Goto Sheets("Data").Range("A1") & Sheets("Data").Range("A1").Offset(0, col).Value = MyDatabase.Fields (col).Name I want to replace the code 'Sheets("Data").Range("A1")' with the variables. Andrew 150208 -- Andrew -- Dave Peterson -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I'm now trying to get the variable from another sheet. I am getting an 'Object required' error on this line. (Cell B8 on the 'Criteria' sheet contains the word 'Data') Set The_Sheet = "Sheets(""" & Sheets("Criteria").Range("B8").Text & """)" -- Andrew "Dave Peterson" wrote: Yep. Thanks for the correction. (Copy and paste is bad...very bad!) JMB wrote: I think you need some set statements: Set The_Sheet = Sheets("Data") Set The_Range = The_Sheet.Range("A1") "Dave Peterson" wrote: Dim The_Sheet As Worksheet Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = The_Sheet.Range("A1") Application.Goto The_Range The_Range.Offset(0, col).Value = MyDatabase.Fields(col).Name But there's no reason to use the application.goto line. Andrew wrote: Hi, Can someone assist with the correct structure for the following: Dim The_Sheet As ?????????????? Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = .Range("A1") Application.Goto Sheets("Data").Range("A1") & Sheets("Data").Range("A1").Offset(0, col).Value = MyDatabase.Fields (col).Name I want to replace the code 'Sheets("Data").Range("A1")' with the variables. Andrew 150208 -- Andrew -- Dave Peterson -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try
Set The_Sheet = Sheets(Sheets("Criteria").Range("B8").Text) "Andrew" wrote: Hi all, I'm now trying to get the variable from another sheet. I am getting an 'Object required' error on this line. (Cell B8 on the 'Criteria' sheet contains the word 'Data') Set The_Sheet = "Sheets(""" & Sheets("Criteria").Range("B8").Text & """)" -- Andrew "Dave Peterson" wrote: Yep. Thanks for the correction. (Copy and paste is bad...very bad!) JMB wrote: I think you need some set statements: Set The_Sheet = Sheets("Data") Set The_Range = The_Sheet.Range("A1") "Dave Peterson" wrote: Dim The_Sheet As Worksheet Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = The_Sheet.Range("A1") Application.Goto The_Range The_Range.Offset(0, col).Value = MyDatabase.Fields(col).Name But there's no reason to use the application.goto line. Andrew wrote: Hi, Can someone assist with the correct structure for the following: Dim The_Sheet As ?????????????? Dim The_Range As Range The_Sheet = Sheets("Data") The_Range = .Range("A1") Application.Goto Sheets("Data").Range("A1") & Sheets("Data").Range("A1").Offset(0, col).Value = MyDatabase.Fields (col).Name I want to replace the code 'Sheets("Data").Range("A1")' with the variables. Andrew 150208 -- Andrew -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula structure | Excel Worksheet Functions | |||
vba structure | Excel Programming | |||
Help with formula structure | Excel Discussion (Misc queries) | |||
if structure help | Excel Programming | |||
Structure of If...Else in VBA | Excel Programming |