Advertisement

05.15.2008 at 08:38AM PDT, ID: 23405594
[x]
Attachment Details

Use variables to reference multiple columns - different on each sheet

Asked by skennedy10 in Microsoft Excel Spreadsheet Software

Tags: Microsoft, Excel, 2003, variables reference ranges

I am new to Excel VBA, but pretty okay with Access.  Actually, it is because I am transferring the data from Excel to Access that I need to know this technique.  

I am okay on making the changes themselves and have had success with that - forcing number formats, date formats, and text formats, but I would like to do more.  When I transfer from Excel to Access, if there is a blank in a date field, I am using

Sub ChangeDateinblankDateColumn()
Dim rngData As Range
Dim rngCell As Range

Set rngData = Range(Range("t2"), Range("t65536").End(xlUp))

For Each rngCell In rngData
    If rngCell = "00/00/0000" Or rngCell = "" Then
        rngCell = "01/01/1900"
    End If
Next
.....
End sub

But I am repeating this for each of the columns that need this.  

For the new "problem," blank number fields,

Set rngData = Range(Range("t2"), Range("t65536").End(xlUp))

For Each rngCell In rngData
    If  rngCell = "" Then
        rngCell = "0"
    End If
Next


Can that somehow be connected to  these two sets of code?

Columns("c:c,e:e,m:m,n:n,u:u,v:v,w:w,y:y,z:z,aa:aa,").Select
Selection.NumberFormat = "0"

Columns("t:t,x:x,g:g,h:h,i:i").Select
Selection.NumberFormat = "m/d/yyyy"

TIA,
Susan
Start Free Trial
[+][-]05.15.2008 at 09:04AM PDT, ID: 21575113

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:19AM PDT, ID: 21575310

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:23AM PDT, ID: 21575372

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:28AM PDT, ID: 21575441

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:36AM PDT, ID: 21575542

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:39AM PDT, ID: 21575579

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:49AM PDT, ID: 21575691

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:58AM PDT, ID: 21575786

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 10:06AM PDT, ID: 21575880

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 10:07AM PDT, ID: 21575896

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 11:58AM PDT, ID: 21576917

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 12:10PM PDT, ID: 21577012

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 12:19PM PDT, ID: 21577086

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Excel Spreadsheet Software
Tags: Microsoft, Excel, 2003, variables reference ranges
Sign Up Now!
Solution Provided By: saurabh726
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.15.2008 at 12:28PM PDT, ID: 21577172

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 02:56PM PDT, ID: 21578302

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 02:57PM PDT, ID: 21578308

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628