Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How To Call VBA Code from Excel 4 Macro | Excel Programming | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming | |||
Using VB to code a Macro within Excel 2000 | Excel Programming | |||
Creating macro code in Excel | Excel Programming |