ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   2 Small VBA Questions; Text To Columns and Naming First Sheet (https://www.excelbanter.com/excel-discussion-misc-queries/141257-2-small-vba-questions%3B-re-text-columns-naming-first-sheet.html)

Brent E

2 Small VBA Questions; Text To Columns and Naming First Sheet
 
Good morning,

First VBA Scenario,
I have a worsksheet where I use a macro to do a "Text To Columns" spread of
data by delimeted width into the next column.

When I run the macro, a dialogue box pops up to prompt if I want to
overwrite the cells in the next column. I need VBA code that will force this
overwrite so the macro will not pause and prompt me to overwrite. Any ideas?

Next VBA Scenario,
I get a weekly spreadsheet from our planning department that has several
tabs. The first tab is usually named "Data - Monthly"; however sometimes the
tabs aren't named consistently, for instance, the first tab may be named
"Data- Monthly".

I run a macro that uses this first sheet, and if the name contains typos the
marco errors out. I need VBA code that will NOT try to look for "Sheet 1" or
name of the first sheet, but will simply reference the first Sheet in the
workbook and then name the sheet a name that I give it in the Macro. This way
the sheet name will always be correct when the macro runs. Please advise.

Thanks Much,



Dave Peterson

2 Small VBA Questions; Text To Columns and Naming First Sheet
 
#1. Try this:

Application.displayalerts = false
'do your data|text to columns
application.displayalerts = true

#2. It's always the leftmost worksheet in the workbook:

dim MonthlyWks as worksheet
set MonthlyWks = worksheets(1)



Brent E wrote:

Good morning,

First VBA Scenario,
I have a worsksheet where I use a macro to do a "Text To Columns" spread of
data by delimeted width into the next column.

When I run the macro, a dialogue box pops up to prompt if I want to
overwrite the cells in the next column. I need VBA code that will force this
overwrite so the macro will not pause and prompt me to overwrite. Any ideas?

Next VBA Scenario,
I get a weekly spreadsheet from our planning department that has several
tabs. The first tab is usually named "Data - Monthly"; however sometimes the
tabs aren't named consistently, for instance, the first tab may be named
"Data- Monthly".

I run a macro that uses this first sheet, and if the name contains typos the
marco errors out. I need VBA code that will NOT try to look for "Sheet 1" or
name of the first sheet, but will simply reference the first Sheet in the
workbook and then name the sheet a name that I give it in the Macro. This way
the sheet name will always be correct when the macro runs. Please advise.

Thanks Much,


--

Dave Peterson

Brent E

2 Small VBA Questions; Text To Columns and Naming First Sh
 
Dave, Thanks for the good help. Solution 1 worked great

In solution 2, do I use this code then to name the left sheet?
Worksheets(1).Name = "JQA"

I am not sure if this will work. Please advise.

Thanks.

"Dave Peterson" wrote:

#1. Try this:

Application.displayalerts = false
'do your data|text to columns
application.displayalerts = true

#2. It's always the leftmost worksheet in the workbook:

dim MonthlyWks as worksheet
set MonthlyWks = worksheets(1)



Brent E wrote:

Good morning,

First VBA Scenario,
I have a worsksheet where I use a macro to do a "Text To Columns" spread of
data by delimeted width into the next column.

When I run the macro, a dialogue box pops up to prompt if I want to
overwrite the cells in the next column. I need VBA code that will force this
overwrite so the macro will not pause and prompt me to overwrite. Any ideas?

Next VBA Scenario,
I get a weekly spreadsheet from our planning department that has several
tabs. The first tab is usually named "Data - Monthly"; however sometimes the
tabs aren't named consistently, for instance, the first tab may be named
"Data- Monthly".

I run a macro that uses this first sheet, and if the name contains typos the
marco errors out. I need VBA code that will NOT try to look for "Sheet 1" or
name of the first sheet, but will simply reference the first Sheet in the
workbook and then name the sheet a name that I give it in the Macro. This way
the sheet name will always be correct when the macro runs. Please advise.

Thanks Much,


--

Dave Peterson


Gord Dibben

2 Small VBA Questions; Text To Columns and Naming First Sheet
 
Brent

Scenario #1

Columns("A:A").Select
Application.DisplayAlerts = False
'T to C code here
Application.DisplayAlerts = True


Gord Dibben MS Excel MVP

On Wed, 2 May 2007 09:21:02 -0700, Brent E
wrote:

Good morning,

First VBA Scenario,
I have a worsksheet where I use a macro to do a "Text To Columns" spread of
data by delimeted width into the next column.

When I run the macro, a dialogue box pops up to prompt if I want to
overwrite the cells in the next column. I need VBA code that will force this
overwrite so the macro will not pause and prompt me to overwrite. Any ideas?

Next VBA Scenario,
I get a weekly spreadsheet from our planning department that has several
tabs. The first tab is usually named "Data - Monthly"; however sometimes the
tabs aren't named consistently, for instance, the first tab may be named
"Data- Monthly".

I run a macro that uses this first sheet, and if the name contains typos the
marco errors out. I need VBA code that will NOT try to look for "Sheet 1" or
name of the first sheet, but will simply reference the first Sheet in the
workbook and then name the sheet a name that I give it in the Macro. This way
the sheet name will always be correct when the macro runs. Please advise.

Thanks Much,



Dave Peterson

2 Small VBA Questions; Text To Columns and Naming First Sh
 
Sometimes, it's easier to just try it to see if it works for you.

But it sure looks like it would work ok -- well, if there isn't a worksheet
named JQA and the workbook isn't protected.

Brent E wrote:

Dave, Thanks for the good help. Solution 1 worked great

In solution 2, do I use this code then to name the left sheet?
Worksheets(1).Name = "JQA"

I am not sure if this will work. Please advise.

Thanks.

"Dave Peterson" wrote:

#1. Try this:

Application.displayalerts = false
'do your data|text to columns
application.displayalerts = true

#2. It's always the leftmost worksheet in the workbook:

dim MonthlyWks as worksheet
set MonthlyWks = worksheets(1)



Brent E wrote:

Good morning,

First VBA Scenario,
I have a worsksheet where I use a macro to do a "Text To Columns" spread of
data by delimeted width into the next column.

When I run the macro, a dialogue box pops up to prompt if I want to
overwrite the cells in the next column. I need VBA code that will force this
overwrite so the macro will not pause and prompt me to overwrite. Any ideas?

Next VBA Scenario,
I get a weekly spreadsheet from our planning department that has several
tabs. The first tab is usually named "Data - Monthly"; however sometimes the
tabs aren't named consistently, for instance, the first tab may be named
"Data- Monthly".

I run a macro that uses this first sheet, and if the name contains typos the
marco errors out. I need VBA code that will NOT try to look for "Sheet 1" or
name of the first sheet, but will simply reference the first Sheet in the
workbook and then name the sheet a name that I give it in the Macro. This way
the sheet name will always be correct when the macro runs. Please advise.

Thanks Much,


--

Dave Peterson


--

Dave Peterson

Brent E

2 Small VBA Questions; Text To Columns and Naming First Sh
 
Gord, Thanks for your assistance and post. I should probably clarify my last
post. I was able to get #1 about turning the alerts on and off to work fine.

What I still need assistance w/ is #2 regarding naming the left most sheet
of a workbook.

Dave, I tried:
Worksheets(1).Name = "JQA"
But am getting an error.

Any thoughts?

"Gord Dibben" wrote:

Brent

Scenario #1

Columns("A:A").Select
Application.DisplayAlerts = False
'T to C code here
Application.DisplayAlerts = True


Gord Dibben MS Excel MVP

On Wed, 2 May 2007 09:21:02 -0700, Brent E
wrote:

Good morning,

First VBA Scenario,
I have a worsksheet where I use a macro to do a "Text To Columns" spread of
data by delimeted width into the next column.

When I run the macro, a dialogue box pops up to prompt if I want to
overwrite the cells in the next column. I need VBA code that will force this
overwrite so the macro will not pause and prompt me to overwrite. Any ideas?

Next VBA Scenario,
I get a weekly spreadsheet from our planning department that has several
tabs. The first tab is usually named "Data - Monthly"; however sometimes the
tabs aren't named consistently, for instance, the first tab may be named
"Data- Monthly".

I run a macro that uses this first sheet, and if the name contains typos the
marco errors out. I need VBA code that will NOT try to look for "Sheet 1" or
name of the first sheet, but will simply reference the first Sheet in the
workbook and then name the sheet a name that I give it in the Macro. This way
the sheet name will always be correct when the macro runs. Please advise.

Thanks Much,




Dave Peterson

2 Small VBA Questions; Text To Columns and Naming First Sh
 
Is the workbook protected?

Is there an existing sheet with that name?

Brent E wrote:

Gord, Thanks for your assistance and post. I should probably clarify my last
post. I was able to get #1 about turning the alerts on and off to work fine.

What I still need assistance w/ is #2 regarding naming the left most sheet
of a workbook.

Dave, I tried:
Worksheets(1).Name = "JQA"
But am getting an error.

Any thoughts?

"Gord Dibben" wrote:

Brent

Scenario #1

Columns("A:A").Select
Application.DisplayAlerts = False
'T to C code here
Application.DisplayAlerts = True


Gord Dibben MS Excel MVP

On Wed, 2 May 2007 09:21:02 -0700, Brent E
wrote:

Good morning,

First VBA Scenario,
I have a worsksheet where I use a macro to do a "Text To Columns" spread of
data by delimeted width into the next column.

When I run the macro, a dialogue box pops up to prompt if I want to
overwrite the cells in the next column. I need VBA code that will force this
overwrite so the macro will not pause and prompt me to overwrite. Any ideas?

Next VBA Scenario,
I get a weekly spreadsheet from our planning department that has several
tabs. The first tab is usually named "Data - Monthly"; however sometimes the
tabs aren't named consistently, for instance, the first tab may be named
"Data- Monthly".

I run a macro that uses this first sheet, and if the name contains typos the
marco errors out. I need VBA code that will NOT try to look for "Sheet 1" or
name of the first sheet, but will simply reference the first Sheet in the
workbook and then name the sheet a name that I give it in the Macro. This way
the sheet name will always be correct when the macro runs. Please advise.

Thanks Much,




--

Dave Peterson


All times are GMT +1. The time now is 09:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com