Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with code for Excel Macro


Hi!
Please help...
I'm trying to code a macro in Excel that has me stumped.
In column A, I have either a letter P or C in each row.
If it's C, I want all the data from columns H, I, J, and K to move to
columns R, S, T, and U within the row.
Any ideas would be greatly appreciated


--
mercedes
------------------------------------------------------------------------
mercedes's Profile: http://www.excelforum.com/member.php...o&userid=24979
View this thread: http://www.excelforum.com/showthread...hreadid=385101

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Need help with code for Excel Macro

Give this a try...

Sub MoveData()
Dim rngToCheck As Range
Dim rngToMove As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rngToCheck = wks.Range("A65536").End(xlUp)

Do While rngToCheck.Row 1
If UCase(Trim(rngToCheck.Value)) = "C" Then
Set rngToMove = Range(rngToCheck.Offset(0, 7), _
rngToCheck.Offset(0, 10))
rngToMove.Copy rngToCheck.Offset(0, 17)
rngToMove.ClearContents
End If
Set rngToCheck = rngToCheck.Offset(-1, 0)
Loop
End Sub

--
HTH...

Jim Thomlinson


"mercedes" wrote:


Hi!
Please help...
I'm trying to code a macro in Excel that has me stumped.
In column A, I have either a letter P or C in each row.
If it's C, I want all the data from columns H, I, J, and K to move to
columns R, S, T, and U within the row.
Any ideas would be greatly appreciated


--
mercedes
------------------------------------------------------------------------
mercedes's Profile: http://www.excelforum.com/member.php...o&userid=24979
View this thread: http://www.excelforum.com/showthread...hreadid=385101


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Need help with code for Excel Macro

Mercedes, I think this should work for you ... or use Jim's answer, but be
warned that if you have any formulas in H, I, J, or K, they will be changed
with the other approach. At least you will also see the benefits of multiple
approaches. Regards, Bill

Sub AdjustLocation()
Dim Cell As Range
For Each Cell In ActiveSheet.Cells(1).EntireColumn.Cells
If Len(Cell) = 0 Then
Exit For
Else
If Cell = "C" Then
With ActiveSheet
.Range("H" & Cell.Row, "K" & Cell.Row).Cut .Range("R" &
Cell.Row)
End With
End If
End If
Next Cell
End Sub


"mercedes" wrote in
message ...

Hi!
Please help...
I'm trying to code a macro in Excel that has me stumped.
In column A, I have either a letter P or C in each row.
If it's C, I want all the data from columns H, I, J, and K to move to
columns R, S, T, and U within the row.
Any ideas would be greatly appreciated


--
mercedes
------------------------------------------------------------------------
mercedes's Profile:
http://www.excelforum.com/member.php...o&userid=24979
View this thread: http://www.excelforum.com/showthread...hreadid=385101



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
How To Call VBA Code from Excel 4 Macro Gaston Excel Programming 4 March 25th 05 09:47 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Ed[_18_] Excel Programming 4 May 20th 04 02:08 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Frank Kabel Excel Programming 0 May 19th 04 08:11 PM
Using VB to code a Macro within Excel 2000 Danny Mayhew Excel Programming 0 February 12th 04 05:37 PM
Creating macro code in Excel Paul Excel Programming 2 October 6th 03 07:07 PM


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