ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Amend code (https://www.excelbanter.com/excel-programming/310664-amend-code.html)

gavmer[_75_]

Amend code
 

Hi all,

The code below copies across a column from a sheet, problem is i
unhides the column. How do i amend so that it copies across the colum
but doesnt unhide it??

Private Sub ComboBox1_Change()
Dim myVal As String
Dim fRng As Range
Dim tRng As Range
Set fRng = Nothing
Set tRng = Worksheets("inclusions").Range("g1")
myVal = Worksheets("inclusions").ComboBox1.Value
Select Case myVal
Case Is = "202"
Set fRng = Worksheets("pricing").Range("e1")
Case Is = "204"
Set fRng = Worksheets("pricing").Range("f1")
Case Is = "205"
Set fRng = Worksheets("pricing").Range("g1")
Case Else
'do nothing???
End Select
If fRng Is Nothing Then
'not 704, 706, 708, 710...
'so do nothing
Else
fRng.EntireColumn.Copy _
Destination:=tRng
End If
End Sub

Cheers!

--
gavme
-----------------------------------------------------------------------
gavmer's Profile: http://www.excelforum.com/member.php...nfo&userid=666
View this thread: http://www.excelforum.com/showthread.php?threadid=26189


Dave Peterson[_3_]

Amend code
 
Maybe you could just hide it when you're done???

right after:

fRng.EntireColumn.Copy _
Destination:=tRng

trng.entirecolumn.hidden = true

(if I picked out the correct column???)



gavmer wrote:

Hi all,

The code below copies across a column from a sheet, problem is it
unhides the column. How do i amend so that it copies across the column
but doesnt unhide it??

Private Sub ComboBox1_Change()
Dim myVal As String
Dim fRng As Range
Dim tRng As Range
Set fRng = Nothing
Set tRng = Worksheets("inclusions").Range("g1")
myVal = Worksheets("inclusions").ComboBox1.Value
Select Case myVal
Case Is = "202"
Set fRng = Worksheets("pricing").Range("e1")
Case Is = "204"
Set fRng = Worksheets("pricing").Range("f1")
Case Is = "205"
Set fRng = Worksheets("pricing").Range("g1")
Case Else
'do nothing???
End Select
If fRng Is Nothing Then
'not 704, 706, 708, 710...
'so do nothing
Else
fRng.EntireColumn.Copy _
Destination:=tRng
End If
End Sub

Cheers!!

--
gavmer
------------------------------------------------------------------------
gavmer's Profile: http://www.excelforum.com/member.php...fo&userid=6662
View this thread: http://www.excelforum.com/showthread...hreadid=261891


--

Dave Peterson



All times are GMT +1. The time now is 03:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com