Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Find Column without Changing Refs in vb

I have the following macro that fillsdown specific columns with formats,
validations, etc. I had to use seperate techniques because I couln not figure
out how to copy an entire row's formats, validations, and formulas without
carring other columns in that rows VALUE data with it (columns without
formats, validations or formulas - data only). This code works good, however,
I am still adding new columns as I see fit. Of course then I have to change
the references in the code when needed. One is there a way to supress columns
with values and copy the row's formats, validations, and formulas only. If
not, is there a way I can scan my column headers in row 1 in each column to
locate the header of choice and then apply my code to the column. This would
prevent having to change the references each time I move a column. Thanks!

Dim lastRow As Long
lastRow = Range("AD65536").End(xlUp).Row
Range("A3:B3").AutoFill Destination:=Range("A3:B" & lastRow)
Range("C3:E3").AutoFill Destination:=Range("C3:E" & lastRow),
Type:=xlFillFormats
Range("I3").Copy
Range("I3:I" & lastRow).PasteSpecial Paste:=xlPasteValidation
Range("K3:L3").AutoFill Destination:=Range("K3:L" & lastRow)
Range("M3:O3").Copy
Range("M3:O" & lastRow).PasteSpecial Paste:=xlPasteValidation

Range("P3:Q3").AutoFill Destination:=Range("P3:Q" & lastRow)
Range("R3:T3").Copy
Range("R3:T" & lastRow).PasteSpecial Paste:=xlPasteValidation

'Range("A3:A" & lastRow) = Range("A3").FormulaArray
Application.ScreenUpdating = True
Sheets("Tracker").Range("A2").Select



End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Find Column without Changing Refs in vb

I'm a bit confused as to what you want to do? You seem to be copying ranges
in row 3 down to the last row? Is this correct? How do you determine which
columns to copy? You could probably create a sub that copies it for one
column and call that repeatedly, but I'm not sure how you determine which
column to work on.

Barb Reinhardt



"Kenny" wrote:

I have the following macro that fillsdown specific columns with formats,
validations, etc. I had to use seperate techniques because I couln not figure
out how to copy an entire row's formats, validations, and formulas without
carring other columns in that rows VALUE data with it (columns without
formats, validations or formulas - data only). This code works good, however,
I am still adding new columns as I see fit. Of course then I have to change
the references in the code when needed. One is there a way to supress columns
with values and copy the row's formats, validations, and formulas only. If
not, is there a way I can scan my column headers in row 1 in each column to
locate the header of choice and then apply my code to the column. This would
prevent having to change the references each time I move a column. Thanks!

Dim lastRow As Long
lastRow = Range("AD65536").End(xlUp).Row
Range("A3:B3").AutoFill Destination:=Range("A3:B" & lastRow)
Range("C3:E3").AutoFill Destination:=Range("C3:E" & lastRow),
Type:=xlFillFormats
Range("I3").Copy
Range("I3:I" & lastRow).PasteSpecial Paste:=xlPasteValidation
Range("K3:L3").AutoFill Destination:=Range("K3:L" & lastRow)
Range("M3:O3").Copy
Range("M3:O" & lastRow).PasteSpecial Paste:=xlPasteValidation

Range("P3:Q3").AutoFill Destination:=Range("P3:Q" & lastRow)
Range("R3:T3").Copy
Range("R3:T" & lastRow).PasteSpecial Paste:=xlPasteValidation

'Range("A3:A" & lastRow) = Range("A3").FormulaArray
Application.ScreenUpdating = True
Sheets("Tracker").Range("A2").Select



End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Find Column without Changing Refs in vb

This sub copies the seperate things that i need for these columns; however,
everytime I add a new column I have to make changes to the referenced columns
in this code. My question is how can I make the code follow the columns as I
make changes to add columns to the worksheet. Such as have the code to search
my header in row 1 & 2 to find the right column and then apply the code to
the right column?

"Barb Reinhardt" wrote:

I'm a bit confused as to what you want to do? You seem to be copying ranges
in row 3 down to the last row? Is this correct? How do you determine which
columns to copy? You could probably create a sub that copies it for one
column and call that repeatedly, but I'm not sure how you determine which
column to work on.

Barb Reinhardt



"Kenny" wrote:

I have the following macro that fillsdown specific columns with formats,
validations, etc. I had to use seperate techniques because I couln not figure
out how to copy an entire row's formats, validations, and formulas without
carring other columns in that rows VALUE data with it (columns without
formats, validations or formulas - data only). This code works good, however,
I am still adding new columns as I see fit. Of course then I have to change
the references in the code when needed. One is there a way to supress columns
with values and copy the row's formats, validations, and formulas only. If
not, is there a way I can scan my column headers in row 1 in each column to
locate the header of choice and then apply my code to the column. This would
prevent having to change the references each time I move a column. Thanks!

Dim lastRow As Long
lastRow = Range("AD65536").End(xlUp).Row
Range("A3:B3").AutoFill Destination:=Range("A3:B" & lastRow)
Range("C3:E3").AutoFill Destination:=Range("C3:E" & lastRow),
Type:=xlFillFormats
Range("I3").Copy
Range("I3:I" & lastRow).PasteSpecial Paste:=xlPasteValidation
Range("K3:L3").AutoFill Destination:=Range("K3:L" & lastRow)
Range("M3:O3").Copy
Range("M3:O" & lastRow).PasteSpecial Paste:=xlPasteValidation

Range("P3:Q3").AutoFill Destination:=Range("P3:Q" & lastRow)
Range("R3:T3").Copy
Range("R3:T" & lastRow).PasteSpecial Paste:=xlPasteValidation

'Range("A3:A" & lastRow) = Range("A3").FormulaArray
Application.ScreenUpdating = True
Sheets("Tracker").Range("A2").Select



End Sub

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
Autofill 1 column with changing data and changing range cdclayton Excel Programming 0 August 5th 08 04:37 PM
Find something in column a then find if column B matches criteria Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 8 November 28th 07 09:40 PM
Changing Range & Cell refs. Stella Excel Programming 1 June 21st 06 01:29 PM
Improve Excel Help Text - Make easier to Find Function Refs RichardAllen Excel Worksheet Functions 0 April 10th 06 05:52 AM
A macro that will change all column refs from one column to another? ModelerGirl Excel Programming 1 February 27th 04 07:12 PM


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