Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Rename a range of cells with a macro

If someone is able to help, I need a macro that will select a given range of
cells then convert them to a new name: See example

If C7:C20 is = 0.1 then replace cell contents with 625

Basically, I need to replace the contents of all cells in a given range
(that contain data) with a constant number like 625. If the cell is blank I
want to leave it blank.
--
Jake
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Rename a range of cells with a macro

Adjust your range as needed.

Sub test()
For Each cell In Range("A1:A5")
If cell.Value < "" _
Then
cell.Value = 625
Else
End If
Next cell
End Sub

HTH,
Paul


"JakeShipley2008" wrote in
message ...
If someone is able to help, I need a macro that will select a given range
of
cells then convert them to a new name: See example

If C7:C20 is = 0.1 then replace cell contents with 625

Basically, I need to replace the contents of all cells in a given range
(that contain data) with a constant number like 625. If the cell is blank
I
want to leave it blank.
--
Jake



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Rename a range of cells with a macro

Thank you so much that worked like a charm, one last question and I should
have it.

I am attaching the macro I am using, additionally I would like to do the
same thing but with I would like to select more ranges and add more cell
values such as the next line I would add would be for E3:E200 and then for
each cell in range D7:D200 make the value 615. Hopefully this makes sense - I
have to add about an additional 70 lines much like I am describing now.

If you can help I would greatly appreciate it.
--
Sub MoveActiveUSL()

lastrow = Sheets("Specs"). _
Cells(Rows.count, "C").End(xlUp).Row
Range("C" & (lastrow + 1)).Select

Sheets("Data Transfer").Select
Range("D3:D200").Select
Selection.Copy
Sheets("Specs").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
lastrow = Sheets("Specs"). _
Cells(Rows.count, "C").End(xlUp).Row
Range("C" & (lastrow + 1)).Select
For Each cell In Range("c7:c200")
If cell.Value < "" _
Then
cell.Value = 625
Else
End If
Next cell
With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = .Cells(.Rows.count, "C").End(xlUp).Row

For Lrow = EndRow To StartRow Step -1

If IsError(.Cells(Lrow, "C").Value) Then
'Do nothing, This avoid a error if there is a error in the
cell

ElseIf .Cells(Lrow, "C").Value = "" Then .Rows(Lrow).Delete

End If
Next
End With


End Sub


Jake


"PCLIVE" wrote:

Adjust your range as needed.

Sub test()
For Each cell In Range("A1:A5")
If cell.Value < "" _
Then
cell.Value = 625
Else
End If
Next cell
End Sub

HTH,
Paul


"JakeShipley2008" wrote in
message ...
If someone is able to help, I need a macro that will select a given range
of
cells then convert them to a new name: See example

If C7:C20 is = 0.1 then replace cell contents with 625

Basically, I need to replace the contents of all cells in a given range
(that contain data) with a constant number like 625. If the cell is blank
I
want to leave it blank.
--
Jake




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
Rename a range . LAB Excel Discussion (Misc queries) 2 April 2nd 09 11:08 PM
Copy, Paste and Rename a Range using a macro [email protected] Excel Discussion (Misc queries) 1 April 15th 08 03:58 PM
Rename Several Defined Range Names with Macro ExcelUser777 Excel Programming 2 January 2nd 07 01:51 PM
rename cells with a macro leonidas[_40_] Excel Programming 2 July 6th 06 03:23 PM
Rename a Range, programatically? plh[_2_] Excel Programming 0 September 4th 03 05:11 PM


All times are GMT +1. The time now is 10:06 AM.

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"