Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 37
Default Possible VBA Code?

Hello,
I have a worksheet with detail data in sheet1 that I'd like to pull over
email add'y in sheet2 if cells in colA are null. Can this be done via a
formula or vba? I'm currently using a pivot table but because we have such a
large volume of data we have poor performance.

COL A COL B COL A (sheet2)
0609
0609

0607

0609


Thank you!
Cathy

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Possible VBA Code?

I'm a little confused as to which way data is supposed to be moved. Looking
at your example, I'm thinking you want to get an email address from column A
of Sheet2 and place it into empty cells in column B of Sheet1.

Question is how to decide which one to pull. Is there a one-to-one
correspondence between the rows on both sheets. That is, if Sheet1!B3 is
empty, can we just get the address in Sheet2!B3 to put into it?

By any chance would the numbers shown as being in Sheet1, column A be found
on Sheet2 in association with the appropriate email addresses?


"Cathy Landry" wrote:

Hello,
I have a worksheet with detail data in sheet1 that I'd like to pull over
email add'y in sheet2 if cells in colA are null. Can this be done via a
formula or vba? I'm currently using a pivot table but because we have such a
large volume of data we have poor performance.

COL A COL B COL A (sheet2)
0609
0609

0607

0609


Thank you!
Cathy

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 37
Default Possible VBA Code?

Hello,

Sheet1 Column A will always contain a mm/yy (we use this for our corp card
programs exp date) Column B will always contain employees email add'y. So,
I'd like to create an email list in sheet2 of all email addresses where the
cells in ColA in Sheet1 are not null. Hope that makes sense :)

"JLatham" wrote:

I'm a little confused as to which way data is supposed to be moved. Looking
at your example, I'm thinking you want to get an email address from column A
of Sheet2 and place it into empty cells in column B of Sheet1.

Question is how to decide which one to pull. Is there a one-to-one
correspondence between the rows on both sheets. That is, if Sheet1!B3 is
empty, can we just get the address in Sheet2!B3 to put into it?

By any chance would the numbers shown as being in Sheet1, column A be found
on Sheet2 in association with the appropriate email addresses?


"Cathy Landry" wrote:

Hello,
I have a worksheet with detail data in sheet1 that I'd like to pull over
email add'y in sheet2 if cells in colA are null. Can this be done via a
formula or vba? I'm currently using a pivot table but because we have such a
large volume of data we have poor performance.

COL A COL B COL A (sheet2)
0609
0609

0607

0609


Thank you!
Cathy

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Possible VBA Code?

Make a copy of your workbook and test this out in it first. Change the names
of the two worksheets in this code to whatever they're really called in the
workbook. To put the code where you can use it, press [Alt]+[F11] to open
the VB editor. Choose Insert Module from the VBE menu. Copy and paste
the code below into the module that appears, make the sheet name changes,
close the VB Editor and use it from Tools Macro Macros.

I assumed you wanted the email addresses to actually be email links, so I've
coded it that way.

Sub MakeEmailList()
Const sourceSheet = "Sheet1" ' change
Const emailListSheet = "Sheet2" ' change

Dim lastSourceRow As Long
Dim sourcePointer As Long
Dim srcRange As Range

Dim emailRange As Range
Dim emailPointer As Long

If Val(Left(Application.Version, 2)) < 12 Then
'in pre-2007 Excel
lastSourceRow = Worksheets(sourceSheet).Range("A" & _
Rows.Count).End(xlUp).Row
emailPointer = Worksheets(emailListSheet).Range("A" & _
Rows.Count).End(xlUp).Row
Else
'in Excel 2007 (or later)
lastSourceRow = Worksheets(sourceSheet).Range("A" & _
Rows.CountLarge).End(xlUp).Row
emailPointer = Worksheets(emailListSheet).Range("A" & _
Rows.CountLarge).End(xlUp).Row
End If
Set srcRange = Worksheets(sourceSheet).Range("A1")
Set emailRange = Worksheets(emailListSheet).Range("A1")
Do While srcRange.Row + sourcePointer <= lastSourceRow
If Not IsEmpty(srcRange.Offset(sourcePointer, 0)) Then
'some entry in column A
'if also an entry in B, assume an email, copy it
If Not IsEmpty(srcRange.Offset(sourcePointer, 1)) Then
emailRange.Offset(emailPointer, 0).Hyperlinks.Add _
Anchor:=emailRange.Offset(emailPointer, 0), _
Address:="mailto:" & srcRange.Offset(sourcePointer, 1).Value, _
TextToDisplay:=srcRange.Offset(sourcePointer, 1).Value
emailPointer = emailPointer + 1
End If
End If
sourcePointer = sourcePointer + 1
Loop
End Sub


"Cathy Landry" wrote:

Hello,

Sheet1 Column A will always contain a mm/yy (we use this for our corp card
programs exp date) Column B will always contain employees email add'y. So,
I'd like to create an email list in sheet2 of all email addresses where the
cells in ColA in Sheet1 are not null. Hope that makes sense :)

"JLatham" wrote:

I'm a little confused as to which way data is supposed to be moved. Looking
at your example, I'm thinking you want to get an email address from column A
of Sheet2 and place it into empty cells in column B of Sheet1.

Question is how to decide which one to pull. Is there a one-to-one
correspondence between the rows on both sheets. That is, if Sheet1!B3 is
empty, can we just get the address in Sheet2!B3 to put into it?

By any chance would the numbers shown as being in Sheet1, column A be found
on Sheet2 in association with the appropriate email addresses?


"Cathy Landry" wrote:

Hello,
I have a worksheet with detail data in sheet1 that I'd like to pull over
email add'y in sheet2 if cells in colA are null. Can this be done via a
formula or vba? I'm currently using a pivot table but because we have such a
large volume of data we have poor performance.

COL A COL B COL A (sheet2)
0609
0609

0607

0609


Thank you!
Cathy

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 37
Default Possible VBA Code?

Works beautifully!!!!!!

Thank you :)


"JLatham" wrote:

Make a copy of your workbook and test this out in it first. Change the names
of the two worksheets in this code to whatever they're really called in the
workbook. To put the code where you can use it, press [Alt]+[F11] to open
the VB editor. Choose Insert Module from the VBE menu. Copy and paste
the code below into the module that appears, make the sheet name changes,
close the VB Editor and use it from Tools Macro Macros.

I assumed you wanted the email addresses to actually be email links, so I've
coded it that way.

Sub MakeEmailList()
Const sourceSheet = "Sheet1" ' change
Const emailListSheet = "Sheet2" ' change

Dim lastSourceRow As Long
Dim sourcePointer As Long
Dim srcRange As Range

Dim emailRange As Range
Dim emailPointer As Long

If Val(Left(Application.Version, 2)) < 12 Then
'in pre-2007 Excel
lastSourceRow = Worksheets(sourceSheet).Range("A" & _
Rows.Count).End(xlUp).Row
emailPointer = Worksheets(emailListSheet).Range("A" & _
Rows.Count).End(xlUp).Row
Else
'in Excel 2007 (or later)
lastSourceRow = Worksheets(sourceSheet).Range("A" & _
Rows.CountLarge).End(xlUp).Row
emailPointer = Worksheets(emailListSheet).Range("A" & _
Rows.CountLarge).End(xlUp).Row
End If
Set srcRange = Worksheets(sourceSheet).Range("A1")
Set emailRange = Worksheets(emailListSheet).Range("A1")
Do While srcRange.Row + sourcePointer <= lastSourceRow
If Not IsEmpty(srcRange.Offset(sourcePointer, 0)) Then
'some entry in column A
'if also an entry in B, assume an email, copy it
If Not IsEmpty(srcRange.Offset(sourcePointer, 1)) Then
emailRange.Offset(emailPointer, 0).Hyperlinks.Add _
Anchor:=emailRange.Offset(emailPointer, 0), _
Address:="mailto:" & srcRange.Offset(sourcePointer, 1).Value, _
TextToDisplay:=srcRange.Offset(sourcePointer, 1).Value
emailPointer = emailPointer + 1
End If
End If
sourcePointer = sourcePointer + 1
Loop
End Sub


"Cathy Landry" wrote:

Hello,

Sheet1 Column A will always contain a mm/yy (we use this for our corp card
programs exp date) Column B will always contain employees email add'y. So,
I'd like to create an email list in sheet2 of all email addresses where the
cells in ColA in Sheet1 are not null. Hope that makes sense :)

"JLatham" wrote:

I'm a little confused as to which way data is supposed to be moved. Looking
at your example, I'm thinking you want to get an email address from column A
of Sheet2 and place it into empty cells in column B of Sheet1.

Question is how to decide which one to pull. Is there a one-to-one
correspondence between the rows on both sheets. That is, if Sheet1!B3 is
empty, can we just get the address in Sheet2!B3 to put into it?

By any chance would the numbers shown as being in Sheet1, column A be found
on Sheet2 in association with the appropriate email addresses?


"Cathy Landry" wrote:

Hello,
I have a worksheet with detail data in sheet1 that I'd like to pull over
email add'y in sheet2 if cells in colA are null. Can this be done via a
formula or vba? I'm currently using a pivot table but because we have such a
large volume of data we have poor performance.

COL A COL B COL A (sheet2)
0609
0609

0607

0609


Thank you!
Cathy



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Possible VBA Code?

You're welcome, enjoy!

"Cathy Landry" wrote:

Works beautifully!!!!!!

Thank you :)


"JLatham" wrote:

Make a copy of your workbook and test this out in it first. Change the names
of the two worksheets in this code to whatever they're really called in the
workbook. To put the code where you can use it, press [Alt]+[F11] to open
the VB editor. Choose Insert Module from the VBE menu. Copy and paste
the code below into the module that appears, make the sheet name changes,
close the VB Editor and use it from Tools Macro Macros.

I assumed you wanted the email addresses to actually be email links, so I've
coded it that way.

Sub MakeEmailList()
Const sourceSheet = "Sheet1" ' change
Const emailListSheet = "Sheet2" ' change

Dim lastSourceRow As Long
Dim sourcePointer As Long
Dim srcRange As Range

Dim emailRange As Range
Dim emailPointer As Long

If Val(Left(Application.Version, 2)) < 12 Then
'in pre-2007 Excel
lastSourceRow = Worksheets(sourceSheet).Range("A" & _
Rows.Count).End(xlUp).Row
emailPointer = Worksheets(emailListSheet).Range("A" & _
Rows.Count).End(xlUp).Row
Else
'in Excel 2007 (or later)
lastSourceRow = Worksheets(sourceSheet).Range("A" & _
Rows.CountLarge).End(xlUp).Row
emailPointer = Worksheets(emailListSheet).Range("A" & _
Rows.CountLarge).End(xlUp).Row
End If
Set srcRange = Worksheets(sourceSheet).Range("A1")
Set emailRange = Worksheets(emailListSheet).Range("A1")
Do While srcRange.Row + sourcePointer <= lastSourceRow
If Not IsEmpty(srcRange.Offset(sourcePointer, 0)) Then
'some entry in column A
'if also an entry in B, assume an email, copy it
If Not IsEmpty(srcRange.Offset(sourcePointer, 1)) Then
emailRange.Offset(emailPointer, 0).Hyperlinks.Add _
Anchor:=emailRange.Offset(emailPointer, 0), _
Address:="mailto:" & srcRange.Offset(sourcePointer, 1).Value, _
TextToDisplay:=srcRange.Offset(sourcePointer, 1).Value
emailPointer = emailPointer + 1
End If
End If
sourcePointer = sourcePointer + 1
Loop
End Sub


"Cathy Landry" wrote:

Hello,

Sheet1 Column A will always contain a mm/yy (we use this for our corp card
programs exp date) Column B will always contain employees email add'y. So,
I'd like to create an email list in sheet2 of all email addresses where the
cells in ColA in Sheet1 are not null. Hope that makes sense :)

"JLatham" wrote:

I'm a little confused as to which way data is supposed to be moved. Looking
at your example, I'm thinking you want to get an email address from column A
of Sheet2 and place it into empty cells in column B of Sheet1.

Question is how to decide which one to pull. Is there a one-to-one
correspondence between the rows on both sheets. That is, if Sheet1!B3 is
empty, can we just get the address in Sheet2!B3 to put into it?

By any chance would the numbers shown as being in Sheet1, column A be found
on Sheet2 in association with the appropriate email addresses?


"Cathy Landry" wrote:

Hello,
I have a worksheet with detail data in sheet1 that I'd like to pull over
email add'y in sheet2 if cells in colA are null. Can this be done via a
formula or vba? I'm currently using a pivot table but because we have such a
large volume of data we have poor performance.

COL A COL B COL A (sheet2)
0609
0609

0607

0609


Thank you!
Cathy

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
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
Unprotect Code Module in Code Damien Excel Discussion (Misc queries) 2 April 18th 06 03:10 PM
Need 2 add second then third code with first code in the Tab View nick s Excel Worksheet Functions 3 December 6th 05 02:20 AM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Write a code by code Excel Discussion (Misc queries) 1 March 23rd 05 02:34 PM


All times are GMT +1. The time now is 03:43 PM.

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"