Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 358
Default Correct structure

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Correct structure

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   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Correct structure

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Correct structure

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 358
Default Correct structure

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   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Correct structure

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
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
Formula structure Excel Erick Excel Worksheet Functions 3 December 25th 08 10:16 AM
vba structure Rick Excel Programming 3 January 8th 08 03:10 AM
Help with formula structure Richard Excel Discussion (Misc queries) 4 October 7th 06 02:35 AM
if structure help filo666 Excel Programming 4 March 1st 05 08:37 PM
Structure of If...Else in VBA John Wilson Excel Programming 2 July 30th 03 04:33 AM


All times are GMT +1. The time now is 11:25 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"