Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default simple excel vba macro

Hi! I am trying to create a VBA macro which will copy the contents of
column B to column C if column B = "group" and column C is blank. I
would also like to insert "EMPTY" into column C only if column B is
blank and is not "group". I am lost on this. Any ideas???

Thanks!!!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default simple excel vba macro

Andrew

Please explain by what you mean by if column B = "group"

Does the word "group" appear in a particular cell, Is "group" a name
Range

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default simple excel vba macro

At what point does it need to stop? there can be a lot of blank cells in column B: 65000

----- Andrew Slentz wrote: ----

Hi! I am trying to create a VBA macro which will copy the contents o
column B to column C if column B = "group" and column C is blank.
would also like to insert "EMPTY" into column C only if column B i
blank and is not "group". I am lost on this. Any ideas??

Thanks!!


*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default simple excel vba macro

I responded to your post on May 8th on this subject,
although your request at that time wasn't exactly the
same. I repeat my May 8th post below. Did this not
work? If so, what was the problem?

***** Repeat of May 8th post *****

Assuming there arn't any gaps in the data then perhaps this
simplification:

Sub Group()
Dim C As Range, NumRows As Integer
Dim Rng1 As Range, Rng2 As Range
NumRows = Range("A65536").End(xlUp).Row
Set Rng1 = Range("D2:I" & NumRows)
Set Rng2 = Range("B2:B" & NumRows)
For Each C In Rng1
If LCase(Trim(Cells(C.Row, 2))) = "group member" Then
C.Value = C.Offset(-1).Value
End If
Next
For Each C In Rng2
If LCase(Trim(C.Value)) = "group" Then
C.EntireRow.Delete
End If
Next
Columns(2).EntireColumn.Delete
End Sub

Regards,
Greg

-----Original Message-----
Hi! I am trying to create a VBA macro which will copy

the contents of
column B to column C if column B = "group" and column C

is blank. I
would also like to insert "EMPTY" into column C only if

column B is
blank and is not "group". I am lost on this. Any

ideas???

Thanks!!!


*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default simple excel vba macro


cLastRow = Celle(Rows.Count,"B").End(xlUp).Row
For i = 1 To cLastRow
If lcase(Cells(i,"B").Value) = "group" Then
If Cells(i,"C").Value = "" Then
Cells(i,"C").Value = "EMPTY")
Else
Cells(i,"C").Value = Cells(i,"B").Value
End If
End If
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Andrew Slentz" wrote in message
...
Hi! I am trying to create a VBA macro which will copy the contents of
column B to column C if column B = "group" and column C is blank. I
would also like to insert "EMPTY" into column C only if column B is
blank and is not "group". I am lost on this. Any ideas???

Thanks!!!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Excel 2007 - Macro to do a simple cut/paste operation. Grindy Excel Discussion (Misc queries) 2 January 26th 09 01:11 AM
why doesn't this simple macro work in excel 2007? ManhattanRebel Excel Discussion (Misc queries) 8 July 19th 08 06:37 PM
Simple Excel Macro TimWillDoIt New Users to Excel 5 April 25th 07 06:17 PM
New Excel user needs help with simple Macro... Rahim Kassam New Users to Excel 1 January 24th 05 02:10 PM
Simple Excel Macro - Please Help Curious[_3_] Excel Programming 7 October 23rd 03 04:26 PM


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